You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ke...@apache.org on 2012/06/26 17:20:25 UTC
[5/58] fixing a bunch of line endings in the test directory
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/dcceb9d5/test/src/com/cloud/test/regression/EventsApiTest.java
----------------------------------------------------------------------
diff --git a/test/src/com/cloud/test/regression/EventsApiTest.java b/test/src/com/cloud/test/regression/EventsApiTest.java
index 55a3428..8e5e9e5 100644
--- a/test/src/com/cloud/test/regression/EventsApiTest.java
+++ b/test/src/com/cloud/test/regression/EventsApiTest.java
@@ -10,165 +10,165 @@
// limitations under the License.
//
// Automatically generated by addcopyright.py at 04/03/2012
-package com.cloud.test.regression;
-
-import java.sql.Statement;
-import java.util.HashMap;
-
-import org.apache.log4j.Logger;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
+package com.cloud.test.regression;
+
+import java.sql.Statement;
+import java.util.HashMap;
+
+import org.apache.log4j.Logger;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
import com.cloud.test.regression.ApiCommand.ResponseType;
-import com.trilead.ssh2.Connection;
-import com.trilead.ssh2.Session;
-
-public class EventsApiTest extends TestCase{
-public static final Logger s_logger = Logger.getLogger(EventsApiTest.class.getName());
-
-
- public EventsApiTest(){
- this.setClient();
- this.setParam(new HashMap<String, String>());
- }
-
- public boolean executeTest(){
- int error=0;
- Element rootElement = this.getInputFile().get(0).getDocumentElement();
- NodeList commandLst = rootElement.getElementsByTagName("command");
-
-
- //Analyze each command, send request and build the array list of api commands
- for (int i=0; i<commandLst.getLength(); i++) {
- Node fstNode = commandLst.item(i);
- Element fstElmnt = (Element) fstNode;
-
-
- //!!!check if we need to execute mySql command
- NodeList commandName = fstElmnt.getElementsByTagName("name");
- Element commandElmnt = (Element) commandName.item(0);
- NodeList commandNm = commandElmnt.getChildNodes();
- if (((Node) commandNm.item(0)).getNodeValue().equals("mysqlupdate")) {
- //establish connection to mysql server and execute an update command
- NodeList mysqlList = fstElmnt.getElementsByTagName("mysqlcommand");
- for (int j=0; j<mysqlList.getLength(); j++) {
- Element itemVariableElement = (Element) mysqlList.item(j);
-
- s_logger.info("Executing mysql command " + itemVariableElement.getTextContent());
- try {
- Statement st = this.getConn().createStatement();
- st.executeUpdate(itemVariableElement.getTextContent());
- } catch (Exception ex) {
- s_logger.error(ex);
- return false;
- }
- }
- }
-
- else if (((Node) commandNm.item(0)).getNodeValue().equals("agentcommand")) {
- //connect to all the agents and execute agent command
- NodeList commandList = fstElmnt.getElementsByTagName("commandname");
- Element commandElement = (Element) commandList.item(0);
- NodeList ipList = fstElmnt.getElementsByTagName("ip");
- for (int j=0; j<ipList.getLength(); j++) {
- Element itemVariableElement = (Element) ipList.item(j);
-
- s_logger.info("Attempting to SSH into agent " + itemVariableElement.getTextContent());
- try {
- Connection conn = new Connection(itemVariableElement.getTextContent());
- conn.connect(null, 60000, 60000);
-
- s_logger.info("SSHed successfully into agent " + itemVariableElement.getTextContent());
-
- boolean isAuthenticated = conn.authenticateWithPassword("root",
- "password");
-
- if (isAuthenticated == false) {
- s_logger.info("Authentication failed for root with password");
- return false;
- }
-
- Session sess = conn.openSession();
- s_logger.info("Executing : " + commandElement.getTextContent());
- sess.execCommand(commandElement.getTextContent());
- Thread.sleep(60000);
- sess.close();
- conn.close();
-
- } catch (Exception ex) {
- s_logger.error(ex);
- return false;
- }
- }
- }
-
- else {
- //new command
- ApiCommand api = new ApiCommand(fstElmnt, this.getParam(), this.getCommands());
-
- //send a command
- api.sendCommand(this.getClient(), null);
-
-
- //verify the response of the command
- if ((api.getResponseType() == ResponseType.ERROR) && (api.getResponseCode() == 200)) {
- s_logger.error("Test case " + api.getTestCaseInfo() + " failed. Command that was supposed to fail, passed. The command was sent with the following url " + api.getUrl());
- error++;
- }
- else if ((api.getResponseType() != ResponseType.ERROR) && (api.getResponseCode() == 200)) {
- //verify if response is suppposed to be empty
- if (api.getResponseType() == ResponseType.EMPTY) {
- if (api.isEmpty() == true) {
- s_logger.info("Test case " + api.getTestCaseInfo() + " passed. Empty response was returned as expected. Command was sent with url " + api.getUrl());
- }
- else {
- s_logger.error("Test case " + api.getTestCaseInfo() + " failed. Empty response was expected. Command was sent with url " + api.getUrl());
- }
- } else {
- if (api.isEmpty() != false)
- s_logger.error("Test case " + api.getTestCaseInfo() + " failed. Non-empty response was expected. Command was sent with url " + api.getUrl());
- else {
- //set parameters for the future use
- if (api.setParam(this.getParam()) == false) {
- s_logger.error("Exiting the test...Command " + api.getName() + " didn't return parameters needed for the future use. The command was sent with url " + api.getUrl());
- return false;
- }
- else if (api.getTestCaseInfo() != null){
- s_logger.info("Test case " + api.getTestCaseInfo() + " passed. Command was sent with the url " + api.getUrl());
- }
- }
- }
- }
- else if ((api.getResponseType() != ResponseType.ERROR) && (api.getResponseCode() != 200)) {
- s_logger.error("Command " + api.getName() + " failed with an error code " + api.getResponseCode() + " . Command was sent with url " + api.getUrl());
- if (api.getRequired() == true) {
- s_logger.info("The command is required for the future use, so exiging");
- return false;
- }
- error++;
- }
- else if (api.getTestCaseInfo() != null){
- s_logger.info("Test case " + api.getTestCaseInfo() + " passed. Command that was supposed to fail, failed. Command was sent with url " + api.getUrl());
-
- }
- }
- }
-
- //verify events with userid parameter - test case 97
- HashMap<String, Integer> expectedEvents = new HashMap<String, Integer>();
- expectedEvents.put("VM.START", 1);
- boolean eventResult = ApiCommand.verifyEvents(expectedEvents, "INFO", "http://" + this.getParam().get("hostip") + ":8096", "userid=" + this.getParam().get("userid1") + "&type=VM.START");
- s_logger.info("Test case 97 - listEvent command verification result is " + eventResult);
-
- //verify error events
- eventResult = ApiCommand.verifyEvents("../metadata/error_events.properties", "ERROR", "http://" + this.getParam().get("hostip") + ":8096", this.getParam().get("erroruseraccount"));
- s_logger.info("listEvent command verification result is " + eventResult);
-
-
- if (error != 0)
- return false;
- else
- return true;
- }
-}
+import com.trilead.ssh2.Connection;
+import com.trilead.ssh2.Session;
+
+public class EventsApiTest extends TestCase{
+public static final Logger s_logger = Logger.getLogger(EventsApiTest.class.getName());
+
+
+ public EventsApiTest(){
+ this.setClient();
+ this.setParam(new HashMap<String, String>());
+ }
+
+ public boolean executeTest(){
+ int error=0;
+ Element rootElement = this.getInputFile().get(0).getDocumentElement();
+ NodeList commandLst = rootElement.getElementsByTagName("command");
+
+
+ //Analyze each command, send request and build the array list of api commands
+ for (int i=0; i<commandLst.getLength(); i++) {
+ Node fstNode = commandLst.item(i);
+ Element fstElmnt = (Element) fstNode;
+
+
+ //!!!check if we need to execute mySql command
+ NodeList commandName = fstElmnt.getElementsByTagName("name");
+ Element commandElmnt = (Element) commandName.item(0);
+ NodeList commandNm = commandElmnt.getChildNodes();
+ if (((Node) commandNm.item(0)).getNodeValue().equals("mysqlupdate")) {
+ //establish connection to mysql server and execute an update command
+ NodeList mysqlList = fstElmnt.getElementsByTagName("mysqlcommand");
+ for (int j=0; j<mysqlList.getLength(); j++) {
+ Element itemVariableElement = (Element) mysqlList.item(j);
+
+ s_logger.info("Executing mysql command " + itemVariableElement.getTextContent());
+ try {
+ Statement st = this.getConn().createStatement();
+ st.executeUpdate(itemVariableElement.getTextContent());
+ } catch (Exception ex) {
+ s_logger.error(ex);
+ return false;
+ }
+ }
+ }
+
+ else if (((Node) commandNm.item(0)).getNodeValue().equals("agentcommand")) {
+ //connect to all the agents and execute agent command
+ NodeList commandList = fstElmnt.getElementsByTagName("commandname");
+ Element commandElement = (Element) commandList.item(0);
+ NodeList ipList = fstElmnt.getElementsByTagName("ip");
+ for (int j=0; j<ipList.getLength(); j++) {
+ Element itemVariableElement = (Element) ipList.item(j);
+
+ s_logger.info("Attempting to SSH into agent " + itemVariableElement.getTextContent());
+ try {
+ Connection conn = new Connection(itemVariableElement.getTextContent());
+ conn.connect(null, 60000, 60000);
+
+ s_logger.info("SSHed successfully into agent " + itemVariableElement.getTextContent());
+
+ boolean isAuthenticated = conn.authenticateWithPassword("root",
+ "password");
+
+ if (isAuthenticated == false) {
+ s_logger.info("Authentication failed for root with password");
+ return false;
+ }
+
+ Session sess = conn.openSession();
+ s_logger.info("Executing : " + commandElement.getTextContent());
+ sess.execCommand(commandElement.getTextContent());
+ Thread.sleep(60000);
+ sess.close();
+ conn.close();
+
+ } catch (Exception ex) {
+ s_logger.error(ex);
+ return false;
+ }
+ }
+ }
+
+ else {
+ //new command
+ ApiCommand api = new ApiCommand(fstElmnt, this.getParam(), this.getCommands());
+
+ //send a command
+ api.sendCommand(this.getClient(), null);
+
+
+ //verify the response of the command
+ if ((api.getResponseType() == ResponseType.ERROR) && (api.getResponseCode() == 200)) {
+ s_logger.error("Test case " + api.getTestCaseInfo() + " failed. Command that was supposed to fail, passed. The command was sent with the following url " + api.getUrl());
+ error++;
+ }
+ else if ((api.getResponseType() != ResponseType.ERROR) && (api.getResponseCode() == 200)) {
+ //verify if response is suppposed to be empty
+ if (api.getResponseType() == ResponseType.EMPTY) {
+ if (api.isEmpty() == true) {
+ s_logger.info("Test case " + api.getTestCaseInfo() + " passed. Empty response was returned as expected. Command was sent with url " + api.getUrl());
+ }
+ else {
+ s_logger.error("Test case " + api.getTestCaseInfo() + " failed. Empty response was expected. Command was sent with url " + api.getUrl());
+ }
+ } else {
+ if (api.isEmpty() != false)
+ s_logger.error("Test case " + api.getTestCaseInfo() + " failed. Non-empty response was expected. Command was sent with url " + api.getUrl());
+ else {
+ //set parameters for the future use
+ if (api.setParam(this.getParam()) == false) {
+ s_logger.error("Exiting the test...Command " + api.getName() + " didn't return parameters needed for the future use. The command was sent with url " + api.getUrl());
+ return false;
+ }
+ else if (api.getTestCaseInfo() != null){
+ s_logger.info("Test case " + api.getTestCaseInfo() + " passed. Command was sent with the url " + api.getUrl());
+ }
+ }
+ }
+ }
+ else if ((api.getResponseType() != ResponseType.ERROR) && (api.getResponseCode() != 200)) {
+ s_logger.error("Command " + api.getName() + " failed with an error code " + api.getResponseCode() + " . Command was sent with url " + api.getUrl());
+ if (api.getRequired() == true) {
+ s_logger.info("The command is required for the future use, so exiging");
+ return false;
+ }
+ error++;
+ }
+ else if (api.getTestCaseInfo() != null){
+ s_logger.info("Test case " + api.getTestCaseInfo() + " passed. Command that was supposed to fail, failed. Command was sent with url " + api.getUrl());
+
+ }
+ }
+ }
+
+ //verify events with userid parameter - test case 97
+ HashMap<String, Integer> expectedEvents = new HashMap<String, Integer>();
+ expectedEvents.put("VM.START", 1);
+ boolean eventResult = ApiCommand.verifyEvents(expectedEvents, "INFO", "http://" + this.getParam().get("hostip") + ":8096", "userid=" + this.getParam().get("userid1") + "&type=VM.START");
+ s_logger.info("Test case 97 - listEvent command verification result is " + eventResult);
+
+ //verify error events
+ eventResult = ApiCommand.verifyEvents("../metadata/error_events.properties", "ERROR", "http://" + this.getParam().get("hostip") + ":8096", this.getParam().get("erroruseraccount"));
+ s_logger.info("listEvent command verification result is " + eventResult);
+
+
+ if (error != 0)
+ return false;
+ else
+ return true;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/dcceb9d5/test/src/com/cloud/test/regression/HA.java
----------------------------------------------------------------------
diff --git a/test/src/com/cloud/test/regression/HA.java b/test/src/com/cloud/test/regression/HA.java
index 9ff843d..cdf2a1c 100644
--- a/test/src/com/cloud/test/regression/HA.java
+++ b/test/src/com/cloud/test/regression/HA.java
@@ -10,65 +10,65 @@
// limitations under the License.
//
// Automatically generated by addcopyright.py at 04/03/2012
-package com.cloud.test.regression;
-
-import org.apache.log4j.Logger;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import com.cloud.test.regression.ApiCommand.ResponseType;
-
-public class HA extends TestCase{
-
- public static final Logger s_logger = Logger.getLogger(HA.class.getName());
-
- public HA(){
- this.setClient();
- }
-
- public boolean executeTest(){
- int error=0;
- Element rootElement = this.getInputFile().get(0).getDocumentElement();
- NodeList commandLst = rootElement.getElementsByTagName("command");
-
- //Analyze each command, send request and build the array list of api commands
- for (int i=0; i<commandLst.getLength(); i++) {
-
- Node fstNode = commandLst.item(i);
- Element fstElmnt = (Element) fstNode;
-
- //new command
- ApiCommand api = new ApiCommand(fstElmnt, this.getParam(), this.getCommands());
-
- //send a command
- api.sendCommand(this.getClient(), this.getConn());
-
- //verify the response parameters
- if ((api.getResponseCode() !=200 ) && (api.getRequired() == true) )
- {
- s_logger.error("Exiting the test....Command " + api.getName() + " required for the future run, failed with an error code " + api.getResponseCode() + ". Command was sent with the url " + api.getUrl());
- return false;
- }
- else if ((api.getResponseCode() != 200) && (api.getResponseType() != ResponseType.ERROR)) {
- error++;
- s_logger.error("Command " + api.getTestCaseInfo() + " failed with an error code " + api.getResponseCode() + " . Command was sent with url " + api.getUrl());
- } else if ((api.getResponseCode() == 200) && (api.getResponseType() == ResponseType.ERROR)) {
- error++;
- s_logger.error("Command " + api.getTestCaseInfo() + " which was supposed to failed, passed. The command was sent with url " + api.getUrl());
- } else {
- //set parameters for the future use
- if (api.setParam(this.getParam()) == false) {
- s_logger.error("Exiting the test...Command " + api.getName() + " didn't return parameters needed for the future use. Command was sent with url " + api.getUrl());
- return false;
- }
- s_logger.info("Command " + api.getTestCaseInfo() + " passed");
- }
- }
-
- if (error != 0)
- return false;
- else
- return true;
- }
-}
+package com.cloud.test.regression;
+
+import org.apache.log4j.Logger;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import com.cloud.test.regression.ApiCommand.ResponseType;
+
+public class HA extends TestCase{
+
+ public static final Logger s_logger = Logger.getLogger(HA.class.getName());
+
+ public HA(){
+ this.setClient();
+ }
+
+ public boolean executeTest(){
+ int error=0;
+ Element rootElement = this.getInputFile().get(0).getDocumentElement();
+ NodeList commandLst = rootElement.getElementsByTagName("command");
+
+ //Analyze each command, send request and build the array list of api commands
+ for (int i=0; i<commandLst.getLength(); i++) {
+
+ Node fstNode = commandLst.item(i);
+ Element fstElmnt = (Element) fstNode;
+
+ //new command
+ ApiCommand api = new ApiCommand(fstElmnt, this.getParam(), this.getCommands());
+
+ //send a command
+ api.sendCommand(this.getClient(), this.getConn());
+
+ //verify the response parameters
+ if ((api.getResponseCode() !=200 ) && (api.getRequired() == true) )
+ {
+ s_logger.error("Exiting the test....Command " + api.getName() + " required for the future run, failed with an error code " + api.getResponseCode() + ". Command was sent with the url " + api.getUrl());
+ return false;
+ }
+ else if ((api.getResponseCode() != 200) && (api.getResponseType() != ResponseType.ERROR)) {
+ error++;
+ s_logger.error("Command " + api.getTestCaseInfo() + " failed with an error code " + api.getResponseCode() + " . Command was sent with url " + api.getUrl());
+ } else if ((api.getResponseCode() == 200) && (api.getResponseType() == ResponseType.ERROR)) {
+ error++;
+ s_logger.error("Command " + api.getTestCaseInfo() + " which was supposed to failed, passed. The command was sent with url " + api.getUrl());
+ } else {
+ //set parameters for the future use
+ if (api.setParam(this.getParam()) == false) {
+ s_logger.error("Exiting the test...Command " + api.getName() + " didn't return parameters needed for the future use. Command was sent with url " + api.getUrl());
+ return false;
+ }
+ s_logger.info("Command " + api.getTestCaseInfo() + " passed");
+ }
+ }
+
+ if (error != 0)
+ return false;
+ else
+ return true;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/dcceb9d5/test/src/com/cloud/test/regression/LoadBalancingTest.java
----------------------------------------------------------------------
diff --git a/test/src/com/cloud/test/regression/LoadBalancingTest.java b/test/src/com/cloud/test/regression/LoadBalancingTest.java
index 71db3a6..531af8f 100644
--- a/test/src/com/cloud/test/regression/LoadBalancingTest.java
+++ b/test/src/com/cloud/test/regression/LoadBalancingTest.java
@@ -10,134 +10,134 @@
// limitations under the License.
//
// Automatically generated by addcopyright.py at 04/03/2012
-package com.cloud.test.regression;
-
-import java.util.HashMap;
-
-import org.apache.log4j.Logger;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
+package com.cloud.test.regression;
+
+import java.util.HashMap;
+
+import org.apache.log4j.Logger;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
import com.cloud.test.regression.ApiCommand.ResponseType;
-
-
-public class LoadBalancingTest extends TestCase{
-
- public static final Logger s_logger = Logger.getLogger(LoadBalancingTest.class.getName());
-
- public LoadBalancingTest(){
- this.setClient();
- this.setParam(new HashMap<String, String>());
- }
-
- public boolean executeTest(){
-
- int error=0;
- Element rootElement = this.getInputFile().get(0).getDocumentElement();
- NodeList commandLst = rootElement.getElementsByTagName("command");
-
- //Analyze each command, send request and build the array list of api commands
- for (int i=0; i<commandLst.getLength(); i++) {
-
- Node fstNode = commandLst.item(i);
- Element fstElmnt = (Element) fstNode;
-
- //new command
- ApiCommand api = new ApiCommand(fstElmnt, this.getParam(), this.getCommands());
-
- //send a command
- api.sendCommand(this.getClient(), null);
-
-
- //verify the response of the command
- if ((api.getResponseType() == ResponseType.ERROR) && (api.getResponseCode() == 200)) {
- s_logger.error("Test case " + api.getTestCaseInfo() + " failed. Command that was supposed to fail, passed. The command was sent with the following url " + api.getUrl());
- error++;
- }
- else if ((api.getResponseType() != ResponseType.ERROR) && (api.getResponseCode() == 200)) {
- //verify if response is suppposed to be empty
- if (api.getResponseType() == ResponseType.EMPTY) {
- if (api.isEmpty() == true) {
- s_logger.info("Test case " + api.getTestCaseInfo() + " passed");
- }
- else {
- s_logger.error("Test case " + api.getTestCaseInfo() + " failed. Empty response was expected. Command was sent with url " + api.getUrl());
- }
- } else {
- if (api.isEmpty() != false)
- s_logger.error("Test case " + api.getTestCaseInfo() + " failed. Non-empty response was expected. Command was sent with url " + api.getUrl());
- else {
- //set parameters for the future use
- if (api.setParam(this.getParam()) == false) {
- s_logger.error("Exiting the test...Command " + api.getName() + " didn't return parameters needed for the future use. The command was sent with url " + api.getUrl());
- return false;
- }
- else if (api.getTestCaseInfo() != null){
- s_logger.info("Test case " + api.getTestCaseInfo() + " passed");
- }
- }
- }
- }
- else if ((api.getResponseType() != ResponseType.ERROR) && (api.getResponseCode() != 200)) {
- s_logger.error("Test case " + api.getTestCaseInfo() + " failed. Command was sent with url " + api.getUrl());
- if (api.getRequired() == true) {
- s_logger.info("The command is required for the future use, so exiging");
- return false;
- }
- error++;
- }
- else if (api.getTestCaseInfo() != null){
- s_logger.info("Test case " + api.getTestCaseInfo() + " passed");
-
- }
- }
-
-// //Try to create portForwarding rule for all available private/public ports
-// ArrayList<String> port = new ArrayList<String>();
-// for (int i=1; i<65536; i++){
-// port.add(Integer.toString(i));
-// }
-//
-// //try all public ports
-// for (String portValue : port) {
-// try {
-// String url = this.getHost() + ":8096/?command=createOrUpdateLoadBalancerRule&account=" + this.getParam().get("accountname") + "&publicip=" + this.getParam().get("boundaryip") +
-// "&privateip=" + this.getParam().get("vmipaddress") + "&privateport=22&protocol=tcp&publicport=" + portValue;
-// HttpClient client = new HttpClient();
-// HttpMethod method = new GetMethod(url);
-// int responseCode = client.executeMethod(method);
-// if (responseCode != 200 ) {
-// error++;
-// s_logger.error("Can't create LB rule for the public port " + portValue + ". Request was sent with url " + url);
-// }
-// }catch (Exception ex) {
-// s_logger.error(ex);
-// }
-// }
-//
-// //try all private ports
-// for (String portValue : port) {
-// try {
-// String url = this.getHost() + ":8096/?command=createOrUpdateLoadBalancerRule&account=" + this.getParam().get("accountname") + "&publicip=" + this.getParam().get("boundaryip") +
-// "&privateip=" + this.getParam().get("vmipaddress") + "&publicport=22&protocol=tcp&privateport=" + portValue;
-// HttpClient client = new HttpClient();
-// HttpMethod method = new GetMethod(url);
-// int responseCode = client.executeMethod(method);
-// if (responseCode != 200 ) {
-// error++;
-// s_logger.error("Can't create LB rule for the private port " + portValue + ". Request was sent with url " + url);
-// }
-// }catch (Exception ex) {
-// s_logger.error(ex);
-// }
-// }
-
-
- if (error != 0)
- return false;
- else
- return true;
- }
-
-}
+
+
+public class LoadBalancingTest extends TestCase{
+
+ public static final Logger s_logger = Logger.getLogger(LoadBalancingTest.class.getName());
+
+ public LoadBalancingTest(){
+ this.setClient();
+ this.setParam(new HashMap<String, String>());
+ }
+
+ public boolean executeTest(){
+
+ int error=0;
+ Element rootElement = this.getInputFile().get(0).getDocumentElement();
+ NodeList commandLst = rootElement.getElementsByTagName("command");
+
+ //Analyze each command, send request and build the array list of api commands
+ for (int i=0; i<commandLst.getLength(); i++) {
+
+ Node fstNode = commandLst.item(i);
+ Element fstElmnt = (Element) fstNode;
+
+ //new command
+ ApiCommand api = new ApiCommand(fstElmnt, this.getParam(), this.getCommands());
+
+ //send a command
+ api.sendCommand(this.getClient(), null);
+
+
+ //verify the response of the command
+ if ((api.getResponseType() == ResponseType.ERROR) && (api.getResponseCode() == 200)) {
+ s_logger.error("Test case " + api.getTestCaseInfo() + " failed. Command that was supposed to fail, passed. The command was sent with the following url " + api.getUrl());
+ error++;
+ }
+ else if ((api.getResponseType() != ResponseType.ERROR) && (api.getResponseCode() == 200)) {
+ //verify if response is suppposed to be empty
+ if (api.getResponseType() == ResponseType.EMPTY) {
+ if (api.isEmpty() == true) {
+ s_logger.info("Test case " + api.getTestCaseInfo() + " passed");
+ }
+ else {
+ s_logger.error("Test case " + api.getTestCaseInfo() + " failed. Empty response was expected. Command was sent with url " + api.getUrl());
+ }
+ } else {
+ if (api.isEmpty() != false)
+ s_logger.error("Test case " + api.getTestCaseInfo() + " failed. Non-empty response was expected. Command was sent with url " + api.getUrl());
+ else {
+ //set parameters for the future use
+ if (api.setParam(this.getParam()) == false) {
+ s_logger.error("Exiting the test...Command " + api.getName() + " didn't return parameters needed for the future use. The command was sent with url " + api.getUrl());
+ return false;
+ }
+ else if (api.getTestCaseInfo() != null){
+ s_logger.info("Test case " + api.getTestCaseInfo() + " passed");
+ }
+ }
+ }
+ }
+ else if ((api.getResponseType() != ResponseType.ERROR) && (api.getResponseCode() != 200)) {
+ s_logger.error("Test case " + api.getTestCaseInfo() + " failed. Command was sent with url " + api.getUrl());
+ if (api.getRequired() == true) {
+ s_logger.info("The command is required for the future use, so exiging");
+ return false;
+ }
+ error++;
+ }
+ else if (api.getTestCaseInfo() != null){
+ s_logger.info("Test case " + api.getTestCaseInfo() + " passed");
+
+ }
+ }
+
+// //Try to create portForwarding rule for all available private/public ports
+// ArrayList<String> port = new ArrayList<String>();
+// for (int i=1; i<65536; i++){
+// port.add(Integer.toString(i));
+// }
+//
+// //try all public ports
+// for (String portValue : port) {
+// try {
+// String url = this.getHost() + ":8096/?command=createOrUpdateLoadBalancerRule&account=" + this.getParam().get("accountname") + "&publicip=" + this.getParam().get("boundaryip") +
+// "&privateip=" + this.getParam().get("vmipaddress") + "&privateport=22&protocol=tcp&publicport=" + portValue;
+// HttpClient client = new HttpClient();
+// HttpMethod method = new GetMethod(url);
+// int responseCode = client.executeMethod(method);
+// if (responseCode != 200 ) {
+// error++;
+// s_logger.error("Can't create LB rule for the public port " + portValue + ". Request was sent with url " + url);
+// }
+// }catch (Exception ex) {
+// s_logger.error(ex);
+// }
+// }
+//
+// //try all private ports
+// for (String portValue : port) {
+// try {
+// String url = this.getHost() + ":8096/?command=createOrUpdateLoadBalancerRule&account=" + this.getParam().get("accountname") + "&publicip=" + this.getParam().get("boundaryip") +
+// "&privateip=" + this.getParam().get("vmipaddress") + "&publicport=22&protocol=tcp&privateport=" + portValue;
+// HttpClient client = new HttpClient();
+// HttpMethod method = new GetMethod(url);
+// int responseCode = client.executeMethod(method);
+// if (responseCode != 200 ) {
+// error++;
+// s_logger.error("Can't create LB rule for the private port " + portValue + ". Request was sent with url " + url);
+// }
+// }catch (Exception ex) {
+// s_logger.error(ex);
+// }
+// }
+
+
+ if (error != 0)
+ return false;
+ else
+ return true;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/dcceb9d5/test/src/com/cloud/test/regression/PortForwardingTest.java
----------------------------------------------------------------------
diff --git a/test/src/com/cloud/test/regression/PortForwardingTest.java b/test/src/com/cloud/test/regression/PortForwardingTest.java
index 13dc424..2942eda 100644
--- a/test/src/com/cloud/test/regression/PortForwardingTest.java
+++ b/test/src/com/cloud/test/regression/PortForwardingTest.java
@@ -10,8 +10,8 @@
// limitations under the License.
//
// Automatically generated by addcopyright.py at 04/03/2012
-package com.cloud.test.regression;
-
+package com.cloud.test.regression;
+
import java.util.HashMap;
import org.apache.log4j.Logger;
@@ -20,123 +20,123 @@ import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import com.cloud.test.regression.ApiCommand.ResponseType;
-
-public class PortForwardingTest extends TestCase{
- public static final Logger s_logger = Logger.getLogger(PortForwardingTest.class.getName());
-
- public PortForwardingTest(){
- this.setClient();
- this.setParam(new HashMap<String, String>());
- }
-
- public boolean executeTest(){
-
- int error=0;
- Element rootElement = this.getInputFile().get(0).getDocumentElement();
- NodeList commandLst = rootElement.getElementsByTagName("command");
-
- //Analyze each command, send request and build the array list of api commands
- for (int i=0; i<commandLst.getLength(); i++) {
-
- Node fstNode = commandLst.item(i);
- Element fstElmnt = (Element) fstNode;
-
- //new command
- ApiCommand api = new ApiCommand(fstElmnt, this.getParam(), this.getCommands());
-
- //send a command
- api.sendCommand(this.getClient(), null);
-
-
- //verify the response of the command
- if ((api.getResponseType() != ResponseType.ERROR) && (api.getResponseCode() == 200)) {
- s_logger.error("Test case " + api.getTestCaseInfo() + " failed. Command that was supposed to fail, passed. The command was sent with the following url " + api.getUrl());
- error++;
- }
- else if ((api.getResponseType() != ResponseType.ERROR) && (api.getResponseCode() == 200)) {
- //verify if response is suppposed to be empty
- if (api.getResponseType() == ResponseType.EMPTY) {
- if (api.isEmpty() == true) {
- s_logger.info("Test case " + api.getTestCaseInfo() + " passed");
- }
- else {
- s_logger.error("Test case " + api.getTestCaseInfo() + " failed. Empty response was expected. Command was sent with url " + api.getUrl());
- }
- } else {
- if (api.isEmpty() != false)
- s_logger.error("Test case " + api.getTestCaseInfo() + " failed. Non-empty response was expected. Command was sent with url " + api.getUrl());
- else {
- //set parameters for the future use
- if (api.setParam(this.getParam()) == false) {
- s_logger.error("Exiting the test...Command " + api.getName() + " didn't return parameters needed for the future use. The command was sent with url " + api.getUrl());
- return false;
- }
- else if (api.getTestCaseInfo() != null){
- s_logger.info("Test case " + api.getTestCaseInfo() + " passed");
- }
- }
- }
- }
- else if ((api.getResponseType() != ResponseType.ERROR) && (api.getResponseCode() != 200)) {
- s_logger.error("Test case " + api.getTestCaseInfo() + " failed . Command was sent with url " + api.getUrl());
- if (api.getRequired() == true) {
- s_logger.info("The command is required for the future use, so exiging");
- return false;
- }
- error++;
- }
- else if (api.getTestCaseInfo() != null){
- s_logger.info("Test case " + api.getTestCaseInfo() + " passed");
-
- }
- }
-
-// //Try to create portForwarding rule for all available private/public ports
-// ArrayList<String> port = new ArrayList<String>();
-// for (int i=1; i<65536; i++){
-// port.add(Integer.toString(i));
-// }
-//
-// //try all public ports
-// for (String portValue : port) {
-// try {
-// s_logger.info("public port is " + portValue);
-// String url = this.getHost() + ":8096/?command=createOrUpdateIpForwardingRule&account=" + this.getParam().get("accountname") + "&publicip=" + this.getParam().get("boundaryip") +
-// "&privateip=" + this.getParam().get("vmipaddress") + "&privateport=22&protocol=tcp&publicport=" + portValue;
-// HttpClient client = new HttpClient();
-// HttpMethod method = new GetMethod(url);
-// int responseCode = client.executeMethod(method);
-// if (responseCode != 200 ) {
-// error++;
-// s_logger.error("Can't create portForwarding rule for the public port " + portValue + ". Request was sent with url " + url);
-// }
-// }catch (Exception ex) {
-// s_logger.error(ex);
-// }
-// }
-//
-// //try all private ports
-// for (String portValue : port) {
-// try {
-// String url = this.getHost() + ":8096/?command=createOrUpdateIpForwardingRule&account=" + this.getParam().get("accountname") + "&publicip=" + this.getParam().get("boundaryip") +
-// "&privateip=" + this.getParam().get("vmipaddress") + "&publicport=22&protocol=tcp&privateport=" + portValue;
-// HttpClient client = new HttpClient();
-// HttpMethod method = new GetMethod(url);
-// int responseCode = client.executeMethod(method);
-// if (responseCode != 200 ) {
-// error++;
-// s_logger.error("Can't create portForwarding rule for the private port " + portValue + ". Request was sent with url " + url);
-// }
-// }catch (Exception ex) {
-// s_logger.error(ex);
-// }
-// }
-
-
- if (error != 0)
- return false;
- else
- return true;
- }
-
-}
+
+public class PortForwardingTest extends TestCase{
+ public static final Logger s_logger = Logger.getLogger(PortForwardingTest.class.getName());
+
+ public PortForwardingTest(){
+ this.setClient();
+ this.setParam(new HashMap<String, String>());
+ }
+
+ public boolean executeTest(){
+
+ int error=0;
+ Element rootElement = this.getInputFile().get(0).getDocumentElement();
+ NodeList commandLst = rootElement.getElementsByTagName("command");
+
+ //Analyze each command, send request and build the array list of api commands
+ for (int i=0; i<commandLst.getLength(); i++) {
+
+ Node fstNode = commandLst.item(i);
+ Element fstElmnt = (Element) fstNode;
+
+ //new command
+ ApiCommand api = new ApiCommand(fstElmnt, this.getParam(), this.getCommands());
+
+ //send a command
+ api.sendCommand(this.getClient(), null);
+
+
+ //verify the response of the command
+ if ((api.getResponseType() != ResponseType.ERROR) && (api.getResponseCode() == 200)) {
+ s_logger.error("Test case " + api.getTestCaseInfo() + " failed. Command that was supposed to fail, passed. The command was sent with the following url " + api.getUrl());
+ error++;
+ }
+ else if ((api.getResponseType() != ResponseType.ERROR) && (api.getResponseCode() == 200)) {
+ //verify if response is suppposed to be empty
+ if (api.getResponseType() == ResponseType.EMPTY) {
+ if (api.isEmpty() == true) {
+ s_logger.info("Test case " + api.getTestCaseInfo() + " passed");
+ }
+ else {
+ s_logger.error("Test case " + api.getTestCaseInfo() + " failed. Empty response was expected. Command was sent with url " + api.getUrl());
+ }
+ } else {
+ if (api.isEmpty() != false)
+ s_logger.error("Test case " + api.getTestCaseInfo() + " failed. Non-empty response was expected. Command was sent with url " + api.getUrl());
+ else {
+ //set parameters for the future use
+ if (api.setParam(this.getParam()) == false) {
+ s_logger.error("Exiting the test...Command " + api.getName() + " didn't return parameters needed for the future use. The command was sent with url " + api.getUrl());
+ return false;
+ }
+ else if (api.getTestCaseInfo() != null){
+ s_logger.info("Test case " + api.getTestCaseInfo() + " passed");
+ }
+ }
+ }
+ }
+ else if ((api.getResponseType() != ResponseType.ERROR) && (api.getResponseCode() != 200)) {
+ s_logger.error("Test case " + api.getTestCaseInfo() + " failed . Command was sent with url " + api.getUrl());
+ if (api.getRequired() == true) {
+ s_logger.info("The command is required for the future use, so exiging");
+ return false;
+ }
+ error++;
+ }
+ else if (api.getTestCaseInfo() != null){
+ s_logger.info("Test case " + api.getTestCaseInfo() + " passed");
+
+ }
+ }
+
+// //Try to create portForwarding rule for all available private/public ports
+// ArrayList<String> port = new ArrayList<String>();
+// for (int i=1; i<65536; i++){
+// port.add(Integer.toString(i));
+// }
+//
+// //try all public ports
+// for (String portValue : port) {
+// try {
+// s_logger.info("public port is " + portValue);
+// String url = this.getHost() + ":8096/?command=createOrUpdateIpForwardingRule&account=" + this.getParam().get("accountname") + "&publicip=" + this.getParam().get("boundaryip") +
+// "&privateip=" + this.getParam().get("vmipaddress") + "&privateport=22&protocol=tcp&publicport=" + portValue;
+// HttpClient client = new HttpClient();
+// HttpMethod method = new GetMethod(url);
+// int responseCode = client.executeMethod(method);
+// if (responseCode != 200 ) {
+// error++;
+// s_logger.error("Can't create portForwarding rule for the public port " + portValue + ". Request was sent with url " + url);
+// }
+// }catch (Exception ex) {
+// s_logger.error(ex);
+// }
+// }
+//
+// //try all private ports
+// for (String portValue : port) {
+// try {
+// String url = this.getHost() + ":8096/?command=createOrUpdateIpForwardingRule&account=" + this.getParam().get("accountname") + "&publicip=" + this.getParam().get("boundaryip") +
+// "&privateip=" + this.getParam().get("vmipaddress") + "&publicport=22&protocol=tcp&privateport=" + portValue;
+// HttpClient client = new HttpClient();
+// HttpMethod method = new GetMethod(url);
+// int responseCode = client.executeMethod(method);
+// if (responseCode != 200 ) {
+// error++;
+// s_logger.error("Can't create portForwarding rule for the private port " + portValue + ". Request was sent with url " + url);
+// }
+// }catch (Exception ex) {
+// s_logger.error(ex);
+// }
+// }
+
+
+ if (error != 0)
+ return false;
+ else
+ return true;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/dcceb9d5/test/src/com/cloud/test/regression/SanityTest.java
----------------------------------------------------------------------
diff --git a/test/src/com/cloud/test/regression/SanityTest.java b/test/src/com/cloud/test/regression/SanityTest.java
index ef7e3cc..343cbbf 100644
--- a/test/src/com/cloud/test/regression/SanityTest.java
+++ b/test/src/com/cloud/test/regression/SanityTest.java
@@ -12,71 +12,71 @@
// Automatically generated by addcopyright.py at 04/03/2012
package com.cloud.test.regression;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.apache.log4j.Logger;
-
-public class SanityTest extends TestCase{
-
- public static final Logger s_logger = Logger.getLogger(SanityTest.class.getName());
-
- public SanityTest(){
- this.setClient();
- }
-
- public boolean executeTest(){
- int error=0;
- Element rootElement = this.getInputFile().get(0).getDocumentElement();
- NodeList commandLst = rootElement.getElementsByTagName("command");
- //Analyze each command, send request and build the array list of api commands
- for (int i=0; i<commandLst.getLength(); i++) {
-
- Node fstNode = commandLst.item(i);
- Element fstElmnt = (Element) fstNode;
-
- //new command
- ApiCommand api = new ApiCommand(fstElmnt, this.getParam(), this.getCommands());
-
- api.sendCommand(this.getClient(), null);
-
- //verify the response parameters
- if ((api.getResponseCode() !=200 ) && (api.getRequired() == true) )
- {
- s_logger.error("Exiting the test....Command " + api.getName() + " required for the future run, failed with an error code " + api.getResponseCode() + ". Command was sent with the url " + api.getUrl());
- return false;
- }
- else if (api.getResponseCode() != 200) {
- error++;
- s_logger.error("Test " + api.getTestCaseInfo() + " failed with an error code " + api.getResponseCode() + " . Command was sent with url " + api.getUrl());
- }
- else {
- //set parameters for the future use
- if (api.setParam(this.getParam()) == false) {
- s_logger.error("Exiting the test...Command " + api.getName() + " didn't return parameters needed for the future use. Command was sent with url " + api.getUrl());
- return false;
- }
-
- //verify parameters
- if (api.verifyParam() == false)
- {
- s_logger.error("Test " + api.getTestCaseInfo() + " failed. Verification for returned parameters failed. The command was sent with url " + api.getUrl());
- error++;
- }
- else if (api.getTestCaseInfo() != null)
- {
- s_logger.info("Test " + api.getTestCaseInfo() + " passed");
- }
- }
- }
-
- //verify event
- boolean eventResult = ApiCommand.verifyEvents("../metadata/func/regression_events.properties", "INFO", "http://" + this.getParam().get("hostip") + ":8096", this.getParam().get("accountname"));
- s_logger.info("listEvent command verification result is " + eventResult);
-
- if (error != 0)
- return false;
- else
- return true;
- }
-}
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.apache.log4j.Logger;
+
+public class SanityTest extends TestCase{
+
+ public static final Logger s_logger = Logger.getLogger(SanityTest.class.getName());
+
+ public SanityTest(){
+ this.setClient();
+ }
+
+ public boolean executeTest(){
+ int error=0;
+ Element rootElement = this.getInputFile().get(0).getDocumentElement();
+ NodeList commandLst = rootElement.getElementsByTagName("command");
+ //Analyze each command, send request and build the array list of api commands
+ for (int i=0; i<commandLst.getLength(); i++) {
+
+ Node fstNode = commandLst.item(i);
+ Element fstElmnt = (Element) fstNode;
+
+ //new command
+ ApiCommand api = new ApiCommand(fstElmnt, this.getParam(), this.getCommands());
+
+ api.sendCommand(this.getClient(), null);
+
+ //verify the response parameters
+ if ((api.getResponseCode() !=200 ) && (api.getRequired() == true) )
+ {
+ s_logger.error("Exiting the test....Command " + api.getName() + " required for the future run, failed with an error code " + api.getResponseCode() + ". Command was sent with the url " + api.getUrl());
+ return false;
+ }
+ else if (api.getResponseCode() != 200) {
+ error++;
+ s_logger.error("Test " + api.getTestCaseInfo() + " failed with an error code " + api.getResponseCode() + " . Command was sent with url " + api.getUrl());
+ }
+ else {
+ //set parameters for the future use
+ if (api.setParam(this.getParam()) == false) {
+ s_logger.error("Exiting the test...Command " + api.getName() + " didn't return parameters needed for the future use. Command was sent with url " + api.getUrl());
+ return false;
+ }
+
+ //verify parameters
+ if (api.verifyParam() == false)
+ {
+ s_logger.error("Test " + api.getTestCaseInfo() + " failed. Verification for returned parameters failed. The command was sent with url " + api.getUrl());
+ error++;
+ }
+ else if (api.getTestCaseInfo() != null)
+ {
+ s_logger.info("Test " + api.getTestCaseInfo() + " passed");
+ }
+ }
+ }
+
+ //verify event
+ boolean eventResult = ApiCommand.verifyEvents("../metadata/func/regression_events.properties", "INFO", "http://" + this.getParam().get("hostip") + ":8096", this.getParam().get("accountname"));
+ s_logger.info("listEvent command verification result is " + eventResult);
+
+ if (error != 0)
+ return false;
+ else
+ return true;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/dcceb9d5/test/src/com/cloud/test/regression/Test.java
----------------------------------------------------------------------
diff --git a/test/src/com/cloud/test/regression/Test.java b/test/src/com/cloud/test/regression/Test.java
index f5ccdba..b17deea 100644
--- a/test/src/com/cloud/test/regression/Test.java
+++ b/test/src/com/cloud/test/regression/Test.java
@@ -10,73 +10,73 @@
// limitations under the License.
//
// Automatically generated by addcopyright.py at 04/03/2012
-package com.cloud.test.regression;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpMethod;
-import org.apache.commons.httpclient.methods.GetMethod;
-import org.apache.log4j.Logger;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-public class Test extends TestCase{
- public static final Logger s_logger = Logger.getLogger(Test.class.getName());
-
- public Test(){
- this.setClient();
- this.setParam(new HashMap<String, String>());
- }
-
- public boolean executeTest(){
-
- int error=0;
- Element rootElement = this.getInputFile().get(0).getDocumentElement();
- NodeList commandLst = rootElement.getElementsByTagName("command");
-
- //Analyze each command, send request and build the array list of api commands
- for (int i=0; i<commandLst.getLength(); i++) {
- Node fstNode = commandLst.item(i);
- Element fstElmnt = (Element) fstNode;
-
- //new command
- ApiCommand api = new ApiCommand(fstElmnt, this.getParam(), this.getCommands());
-
- //send a command
- api.sendCommand(this.getClient(), null);
-
- }
-
- //Try to create portForwarding rule for all available private/public ports
- ArrayList<String> port = new ArrayList<String>();
- for (int j=1; j<1000; j++){
- port.add(Integer.toString(j));
- }
-
- //try all public ports
- for (String portValue : port) {
- try {
- s_logger.info("public port is " + portValue);
- String url = "http://" + this.getParam().get("hostip") + ":8096/?command=createNetworkRule&publicPort=" + portValue + "&privatePort=22&protocol=tcp&isForward=true&securityGroupId=1&account=admin";
- HttpClient client = new HttpClient();
- HttpMethod method = new GetMethod(url);
- int responseCode = client.executeMethod(method);
- if (responseCode != 200 ) {
- error++;
- s_logger.error("Can't create portForwarding network rule for the public port " + portValue + ". Request was sent with url " + url);
- }
- }catch (Exception ex) {
- s_logger.error(ex);
- }
- }
-
-
- if (error != 0)
- return false;
- else
- return true;
- }
-}
+package com.cloud.test.regression;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpMethod;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.log4j.Logger;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+public class Test extends TestCase{
+ public static final Logger s_logger = Logger.getLogger(Test.class.getName());
+
+ public Test(){
+ this.setClient();
+ this.setParam(new HashMap<String, String>());
+ }
+
+ public boolean executeTest(){
+
+ int error=0;
+ Element rootElement = this.getInputFile().get(0).getDocumentElement();
+ NodeList commandLst = rootElement.getElementsByTagName("command");
+
+ //Analyze each command, send request and build the array list of api commands
+ for (int i=0; i<commandLst.getLength(); i++) {
+ Node fstNode = commandLst.item(i);
+ Element fstElmnt = (Element) fstNode;
+
+ //new command
+ ApiCommand api = new ApiCommand(fstElmnt, this.getParam(), this.getCommands());
+
+ //send a command
+ api.sendCommand(this.getClient(), null);
+
+ }
+
+ //Try to create portForwarding rule for all available private/public ports
+ ArrayList<String> port = new ArrayList<String>();
+ for (int j=1; j<1000; j++){
+ port.add(Integer.toString(j));
+ }
+
+ //try all public ports
+ for (String portValue : port) {
+ try {
+ s_logger.info("public port is " + portValue);
+ String url = "http://" + this.getParam().get("hostip") + ":8096/?command=createNetworkRule&publicPort=" + portValue + "&privatePort=22&protocol=tcp&isForward=true&securityGroupId=1&account=admin";
+ HttpClient client = new HttpClient();
+ HttpMethod method = new GetMethod(url);
+ int responseCode = client.executeMethod(method);
+ if (responseCode != 200 ) {
+ error++;
+ s_logger.error("Can't create portForwarding network rule for the public port " + portValue + ". Request was sent with url " + url);
+ }
+ }catch (Exception ex) {
+ s_logger.error(ex);
+ }
+ }
+
+
+ if (error != 0)
+ return false;
+ else
+ return true;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/dcceb9d5/test/src/com/cloud/test/regression/TestCase.java
----------------------------------------------------------------------
diff --git a/test/src/com/cloud/test/regression/TestCase.java b/test/src/com/cloud/test/regression/TestCase.java
index 8b68e52..3eefa4c 100644
--- a/test/src/com/cloud/test/regression/TestCase.java
+++ b/test/src/com/cloud/test/regression/TestCase.java
@@ -10,8 +10,8 @@
// limitations under the License.
//
// Automatically generated by addcopyright.py at 04/03/2012
-package com.cloud.test.regression;
-
+package com.cloud.test.regression;
+
import java.io.File;
import java.io.FileInputStream;
import java.sql.Connection;
@@ -27,24 +27,24 @@ import javax.xml.parsers.DocumentBuilderFactory;
import org.apache.commons.httpclient.HttpClient;
import org.apache.log4j.Logger;
import org.w3c.dom.Document;
-
-
-public abstract class TestCase{
-
- public static Logger s_logger = Logger.getLogger(TestCase.class.getName());
- private Connection conn;
- private ArrayList <Document> inputFile = new ArrayList<Document> ();
- private HttpClient client;
- private String testCaseName;
+
+
+public abstract class TestCase{
+
+ public static Logger s_logger = Logger.getLogger(TestCase.class.getName());
+ private Connection conn;
+ private ArrayList <Document> inputFile = new ArrayList<Document> ();
+ private HttpClient client;
+ private String testCaseName;
private HashMap<String, String> param = new HashMap<String, String> ();
- private HashMap<String, String> commands = new HashMap<String, String> ();
-
- public HashMap<String, String> getParam() {
- return param;
- }
-
- public void setParam(HashMap<String, String> param) {
- this.param = param;
+ private HashMap<String, String> commands = new HashMap<String, String> ();
+
+ public HashMap<String, String> getParam() {
+ return param;
+ }
+
+ public void setParam(HashMap<String, String> param) {
+ this.param = param;
}
@@ -73,26 +73,26 @@ public abstract class TestCase{
s_logger.info("Unable to find the file " + param.get("apicommands") + " due to following exception " + ex);
}
- }
-
- public Connection getConn() {
- return conn;
- }
-
- public void setConn(String dbPassword) {
- this.conn = null;
- try {
- Class.forName("com.mysql.jdbc.Driver");
- this.conn=DriverManager.getConnection("jdbc:mysql://" + param.get("db") + "/cloud", "root", dbPassword);
- if (!this.conn.isValid(0)) {
- s_logger.error("Connection to DB failed to establish");
- }
-
- }catch (Exception ex) {
- s_logger.error(ex);
- }
- }
-
+ }
+
+ public Connection getConn() {
+ return conn;
+ }
+
+ public void setConn(String dbPassword) {
+ this.conn = null;
+ try {
+ Class.forName("com.mysql.jdbc.Driver");
+ this.conn=DriverManager.getConnection("jdbc:mysql://" + param.get("db") + "/cloud", "root", dbPassword);
+ if (!this.conn.isValid(0)) {
+ s_logger.error("Connection to DB failed to establish");
+ }
+
+ }catch (Exception ex) {
+ s_logger.error(ex);
+ }
+ }
+
public void setInputFile (ArrayList<String> fileNameInput) {
for (String fileName: fileNameInput) {
File file = new File(fileName);
@@ -106,31 +106,31 @@ public abstract class TestCase{
s_logger.error("Unable to load " + fileName + " due to ", ex);
}
this.inputFile.add(doc);
- }
- }
-
- public ArrayList<Document> getInputFile() {
- return inputFile;
- }
-
- public void setTestCaseName(String testCaseName) {
- this.testCaseName = testCaseName;
- }
-
- public String getTestCaseName(){
- return this.testCaseName;
- }
-
- public void setClient() {
- HttpClient client = new HttpClient();
- this.client = client;
- }
-
- public HttpClient getClient() {
- return this.client;
- }
-
- //abstract methods
- public abstract boolean executeTest();
-
-}
+ }
+ }
+
+ public ArrayList<Document> getInputFile() {
+ return inputFile;
+ }
+
+ public void setTestCaseName(String testCaseName) {
+ this.testCaseName = testCaseName;
+ }
+
+ public String getTestCaseName(){
+ return this.testCaseName;
+ }
+
+ public void setClient() {
+ HttpClient client = new HttpClient();
+ this.client = client;
+ }
+
+ public HttpClient getClient() {
+ return this.client;
+ }
+
+ //abstract methods
+ public abstract boolean executeTest();
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/dcceb9d5/test/src/com/cloud/test/regression/VMApiTest.java
----------------------------------------------------------------------
diff --git a/test/src/com/cloud/test/regression/VMApiTest.java b/test/src/com/cloud/test/regression/VMApiTest.java
index 30a086c..917b5bf 100644
--- a/test/src/com/cloud/test/regression/VMApiTest.java
+++ b/test/src/com/cloud/test/regression/VMApiTest.java
@@ -10,55 +10,55 @@
// limitations under the License.
//
// Automatically generated by addcopyright.py at 04/03/2012
-package com.cloud.test.regression;
-
-import java.util.HashMap;
-
-import org.apache.log4j.Logger;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
+package com.cloud.test.regression;
+
+import java.util.HashMap;
+
+import org.apache.log4j.Logger;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
import com.cloud.test.regression.ApiCommand.ResponseType;
-
-
-public class VMApiTest extends TestCase{
-public static final Logger s_logger = Logger.getLogger(VMApiTest.class.getName());
-
-
- public VMApiTest(){
- this.setClient();
- this.setParam(new HashMap<String, String>());
- }
-
- public boolean executeTest(){
- int error=0;
- Element rootElement = this.getInputFile().get(0).getDocumentElement();
- NodeList commandLst = rootElement.getElementsByTagName("command");
-
- //Analyze each command, send request and build the array list of api commands
- for (int i=0; i<commandLst.getLength(); i++) {
- Node fstNode = commandLst.item(i);
- Element fstElmnt = (Element) fstNode;
-
- //new command
- ApiCommand api = new ApiCommand(fstElmnt, this.getParam(), this.getCommands());
-
- //send a command
- api.sendCommand(this.getClient(), this.getConn());
-
-
- //verify the response of the command
- if ((api.getResponseType() == ResponseType.ERROR) && (api.getResponseCode() == 200)) {
- s_logger.error("Test case " + api.getTestCaseInfo() + " failed. Command that was supposed to fail, passed. The command was sent with the following url " + api.getUrl());
- error++;
- }
- else if ((api.getResponseType() != ResponseType.ERROR) && (api.getResponseCode() == 200)) {
- //set parameters for the future use
- if (api.setParam(this.getParam()) == false) {
- s_logger.error("Exiting the test...Command " + api.getName() + " didn't return parameters needed for the future use. The command was sent with url " + api.getUrl());
- return false;
- }
+
+
+public class VMApiTest extends TestCase{
+public static final Logger s_logger = Logger.getLogger(VMApiTest.class.getName());
+
+
+ public VMApiTest(){
+ this.setClient();
+ this.setParam(new HashMap<String, String>());
+ }
+
+ public boolean executeTest(){
+ int error=0;
+ Element rootElement = this.getInputFile().get(0).getDocumentElement();
+ NodeList commandLst = rootElement.getElementsByTagName("command");
+
+ //Analyze each command, send request and build the array list of api commands
+ for (int i=0; i<commandLst.getLength(); i++) {
+ Node fstNode = commandLst.item(i);
+ Element fstElmnt = (Element) fstNode;
+
+ //new command
+ ApiCommand api = new ApiCommand(fstElmnt, this.getParam(), this.getCommands());
+
+ //send a command
+ api.sendCommand(this.getClient(), this.getConn());
+
+
+ //verify the response of the command
+ if ((api.getResponseType() == ResponseType.ERROR) && (api.getResponseCode() == 200)) {
+ s_logger.error("Test case " + api.getTestCaseInfo() + " failed. Command that was supposed to fail, passed. The command was sent with the following url " + api.getUrl());
+ error++;
+ }
+ else if ((api.getResponseType() != ResponseType.ERROR) && (api.getResponseCode() == 200)) {
+ //set parameters for the future use
+ if (api.setParam(this.getParam()) == false) {
+ s_logger.error("Exiting the test...Command " + api.getName() + " didn't return parameters needed for the future use. The command was sent with url " + api.getUrl());
+ return false;
+ }
//verify parameters
if (api.verifyParam() == false)
{
@@ -68,24 +68,24 @@ public static final Logger s_logger = Logger.getLogger(VMApiTest.class.getName()
else
{
s_logger.info("Test " + api.getTestCaseInfo() + " passed");
- }
- }
- else if ((api.getResponseType() != ResponseType.ERROR) && (api.getResponseCode() != 200)) {
- s_logger.error("Test case " + api.getTestCaseInfo() + " failed with an error code " + api.getResponseCode() + " . Command was sent with url " + api.getUrl());
- if (api.getRequired() == true) {
- s_logger.info("The command is required for the future use, so exiging");
- return false;
- }
- error++;
- }
- else if (api.getTestCaseInfo() != null){
- s_logger.info("Test case " + api.getTestCaseInfo() + " passed");
-
- }
- }
- if (error != 0)
- return false;
- else
- return true;
- }
-}
+ }
+ }
+ else if ((api.getResponseType() != ResponseType.ERROR) && (api.getResponseCode() != 200)) {
+ s_logger.error("Test case " + api.getTestCaseInfo() + " failed with an error code " + api.getResponseCode() + " . Command was sent with url " + api.getUrl());
+ if (api.getRequired() == true) {
+ s_logger.info("The command is required for the future use, so exiging");
+ return false;
+ }
+ error++;
+ }
+ else if (api.getTestCaseInfo() != null){
+ s_logger.info("Test case " + api.getTestCaseInfo() + " passed");
+
+ }
+ }
+ if (error != 0)
+ return false;
+ else
+ return true;
+ }
+}