#include "testConnectionHandler.hpp" CPPUNIT_TEST_SUITE_REGISTRATION (testConnectionHandler); void testConnectionHandler::setUp (void) { nodesIP="10.72.57.222" ; cliHandle = new CLIHandler(); outputHandle = new outputHandler(); int ac = 6; char *av[] = {"--verbose", "--mode=\"7-mode\"", "--nodes=10.72.57.222", "--preset-file=\"mypresetfile\"", "--sshprivatekey-file=\"myperf\"", "--SSH"} ; cliHandle->collectCLIOptions(ac, av, outputHandle); connectionHandle = new connectionHandler(nodesIP, cliHandle->getRequestTimeoutSecs(), outputHandle, cliHandle); } void testConnectionHandler::tearDown(void) { delete cliHandle; delete outputHandle; delete connectionHandle; } /** test the connectionHandler classs's primary function which connects to the filer and execute some command * and process them */ void testConnectionHandler:: connectAndExecute(void) { bool connectionStatus; string command = "version"; string passwd="jemmy123"; //Try to connect with default user 'root' for 7-mode with password connectionStatus=connectionHandle->connectToFiler(passwd); CPPUNIT_ASSERT_EQUAL (connectionStatus, true); //Send a command to the filer bool success = connectionHandle->sendCommandToFiler(command); CPPUNIT_ASSERT_EQUAL (success, true); //Read the response from the filer string result = connectionHandle->readResponseFromFiler(15); CPPUNIT_ASSERT (strstr(result.c_str(),"NetApp")); } void testConnectionHandler::disconnectTest (void) { bool status=false; connectionHandle->disconnectToFiler(); //To confirm the disconnection from Filer, try sending one command over the same ssh channel string command = "version"; status = connectionHandle->sendCommandToFiler(command); CPPUNIT_ASSERT_EQUAL (status, false); }