view src/org/thermostat/qa/testsuites/GuiClientWebStorageTest.java @ 168:af42c142855f

fixes of outputtexts, scripts and tests: - outputtexts (help texts) are updated - lot of sleeps added (or increased sleep time) in tests to make them more reliable (preventing random failitures) - added missing credential to CommandChannelSmokeTest and scripts (where local storage exception was needed before) - patterns/1.1.0/noAA/ClientPreferencesDialog/web_storage_connection_info2.png: added missing file - src/org/thermostat/qa/framework/Patterns.java: removed web_storage_connection_info3 from list because this pattern is not present for any version of thermostat - src/org/thermostat/qa/testsuites/GuiClientSmokeTest.java(testStartGUIWithStorageMenuHelpAboutTest): "clicking on close button" is used to close about dialog instead of "pressing enter" which had not worked
author Zdenek Zambersky <zzambers@redhat.com>
date Mon, 01 Dec 2014 16:23:03 +0100
parents 3d06e2d323cb
children
line wrap: on
line source

/*

    ThermostatQA - test framework for Thermostat Monitoring Tool

    Copyright 2013 Red Hat, Inc.

This file is part of ThermostatQA

ThermostatQA is distributed under the GNU General Public License,
version 2 or any later version (with a special exception described
below, commonly known as the "Classpath Exception").

A copy of GNU General Public License (GPL) is included in this
distribution, in the file COPYING.

Linking ThermostatQA code with other modules is making a combined work
based on ThermostatQA.  Thus, the terms and conditions of the GPL
cover the whole combination.

As a special exception, the copyright holders of ThermostatQA give you
permission to link this code with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module.  An independent module is a module which is not derived from
or based on ThermostatQA code.  If you modify ThermostatQA, you may
extend this exception to your version of the software, but you are
not obligated to do so.  If you do not wish to do so, delete this
exception statement from your version.
*/

package org.thermostat.qa.testsuites;

import java.awt.AWTException;
import java.awt.Rectangle;
import java.awt.event.KeyEvent;
import java.io.IOException;
import java.util.List;



import org.thermostat.qa.framework.GuiRobot;
import org.thermostat.qa.framework.Patterns;
import org.thermostat.qa.framework.ThermostatGuiTest;
import org.thermostat.qa.annotations.SinceVersion;
import org.thermostat.qa.annotations.StorageType;
import org.thermostat.qa.annotations.StorageTypes;
import org.thermostat.qa.annotations.TestType;
import org.thermostat.qa.annotations.TestTypes;
import org.thermostat.qa.annotations.TillVersion;

/**
 * Class AgentTest
 * contains basic smoke tests for starting the Thermostat agent. Starting the agent without
 * various parts of web storage (which should not work) and with web storage is checked.
 *
 */
@TestType(TestTypes.GUI_TEST)
@StorageType(StorageTypes.WEBTOMCAT_STORAGE)
public class GuiClientWebStorageTest extends ThermostatGuiTest
{
    private String[] thermGuiWithTomcatOnlyThermostatLogs;
    private String[] thermGuiWithTomcatOnlyCatalinaLogs;
    private String[] thermGuiWithWebStorageThermostatLogs;
    private String[] thermGuiWithWebStorageCatalinaLogs;
    private String[] thermGuiBadLoginCatalinaLogs;
    
    protected void setCheckedStrings() throws IOException
    {
        thermGuiWithTomcatOnlyThermostatLogs = new String[] {
            "com.mongodb.MongoException.Network: Read operation to server /127.0.0.1:"+getMongoPortString()+" failed on database thermostat",
            "java.net.ConnectException: Connection refused"
            };
        thermGuiWithTomcatOnlyCatalinaLogs = new String[] {
            "WebStorageEndPoint: Initializing web service",
            "WebStorageEndPoint: THERMOSTAT_HOME == " + this.configuration.getThermostatHome(),
            "WARNING - MongoConnection: Failed to connect to storage",
            "com.mongodb.MongoException.Network: Read operation to server /127.0.0.1:"+getMongoPortString()+" failed on database thermostat",
            "java.net.ConnectException: Connection refused"
        };
       
        thermGuiWithWebStorageThermostatLogs = new String[] {
            "WebStorageEndPoint: Initializing web service",
            "WebStorageEndPoint: THERMOSTAT_HOME == " + this.configuration.getThermostatHome(),
            "MongoConnection: Using plain socket for mongodb://",
            "WebStorageEndPoint: (id: 0) registered non-aggreate category: vm-cpu-stats|com.redhat.thermostat.vm.cpu.common.model.VmCpuStat|{timeStamp=Key: timeStamp, agentId=Key: agentId, vmId=Key: vmId, cpuLoad=Key: cpuLoad}",
            "WebStorageEndPoint: (id: 1) registered non-aggreate category: vm-heap-info|com.redhat.thermostat.vm.heap.analysis.common.model.HeapInfo|{timeStamp=Key: timeStamp, agentId=Key: agentId, vmId=Key: vmId, heapId=Key: heapId, heapDumpId=Key: heapDumpId, histogramId=Key: histogramId}",
            "WebStorageEndPoint: (id: 2) registered non-aggreate category: vm-gc-stats|com.redhat.thermostat.vm.gc.common.model.VmGcStat|{runCount=Key: runCount, timeStamp=Key: timeStamp, agentId=Key: agentId, vmId=Key: vmId, wallTime=Key: wallTime, collectorName=Key: collectorName}",
            "WebStorageEndPoint: (id: 3) registered non-aggreate category: vm-memory-stats|com.redhat.thermostat.vm.memory.common.model.VmMemoryStat|{timeStamp=Key: timeStamp, generations=Key: generations, agentId=Key: agentId, vmId=Key: vmId}",
            "WebStorageEndPoint: (id: 4) registered non-aggreate category: numa-stat|com.redhat.thermostat.numa.common.NumaStat|{nodeStats=Key: nodeStats, timeStamp=Key: timeStamp, agentId=Key: agentId}",
            "WebStorageEndPoint: (id: 5) registered non-aggreate category: numa-host-info|com.redhat.thermostat.numa.common.NumaHostInfo|{agentId=Key: agentId, hostNumNumaNodes=Key: hostNumNumaNodes}",
            "WebStorageEndPoint: (id: 6) registered non-aggreate category: memory-stats|com.redhat.thermostat.host.memory.common.model.MemoryStat|{total=Key: total, cached=Key: cached, free=Key: free, timeStamp=Key: timeStamp, swapFree=Key: swapFree, swapTotal=Key: swapTotal, buffers=Key: buffers, agentId=Key: agentId, commitLimit=Key: commitLimit}"
            };
        
        thermGuiWithWebStorageCatalinaLogs = new String[] {
            "INFO: Deploying web application directory",
            "/webapps/thermostat",
            "WebStorageEndPoint: Initializing web service",
            "WebStorageEndPoint: THERMOSTAT_HOME == " + this.configuration.getThermostatHome(),
            "MongoConnection: Using plain socket for mongodb://",
            "WebStorageEndPoint: (id: 0) registered non-aggreate category: vm-cpu-stats|com.redhat.thermostat.vm.cpu.common.model.VmCpuStat|{timeStamp=Key: timeStamp, agentId=Key: agentId, vmId=Key: vmId, cpuLoad=Key: cpuLoad}",
            "WebStorageEndPoint: (id: 1) registered non-aggreate category: vm-heap-info|com.redhat.thermostat.vm.heap.analysis.common.model.HeapInfo|{timeStamp=Key: timeStamp, agentId=Key: agentId, vmId=Key: vmId, heapId=Key: heapId, heapDumpId=Key: heapDumpId, histogramId=Key: histogramId}",
            "WebStorageEndPoint: (id: 2) registered non-aggreate category: vm-gc-stats|com.redhat.thermostat.vm.gc.common.model.VmGcStat|{runCount=Key: runCount, timeStamp=Key: timeStamp, agentId=Key: agentId, vmId=Key: vmId, wallTime=Key: wallTime, collectorName=Key: collectorName}",
            "WebStorageEndPoint: (id: 3) registered non-aggreate category: vm-memory-stats|com.redhat.thermostat.vm.memory.common.model.VmMemoryStat|{timeStamp=Key: timeStamp, generations=Key: generations, agentId=Key: agentId, vmId=Key: vmId}",
            "WebStorageEndPoint: (id: 4) registered non-aggreate category: numa-stat|com.redhat.thermostat.numa.common.NumaStat|{nodeStats=Key: nodeStats, timeStamp=Key: timeStamp, agentId=Key: agentId}"
            };
        
        thermGuiBadLoginCatalinaLogs = new String[] {
            "org.apache.catalina.realm.JAASRealm authenticate",
            "WARNING: Login exception authenticating username \"time-for-tea\"",
            "javax.security.auth.login.LoginException: User 'time-for-tea' not found"
        };
    }
    
    protected List<String> listAgents() throws IOException
    {
        logInfo("lists agents", "if any");
        List<String> output = runHelperBashScript("list_all_therm_agents.sh");
        for (String message : output)
        {
            logInfo("Agent list", message);
        }    
        return output;
    }
    
    @Override
    protected void tearDown()
    {
        try
        {
            //stopWebStorage();
            restoreNormalStorageConfigFiles();
        }
        catch (IOException e)
        {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }      
    }

    @Override
    protected void setUp()
    {
        try
        {
            setCheckedStrings();
            eraseTomcatOutputFiles();
            prepareWebStorageConfigFiles();
        }
        catch (IOException e)
        {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        
    }

    /**
     * Method checkForErrorIconAndClickQuit
     * checks the presence of error icon and configure button patterns 
     * and then checks and clicks the quit button.
     * 
     * Following patterns have been used:<br />
     * <img src="patterns/AA/FailureToConnectToStorageDialog/error_icon.png"><br /><br />
     * <img src="patterns/AA/FailureToConnectToStorageDialog/configure_button.png"><br /><br />
     * <img src="patterns/AA/FailureToConnectToStorageDialog/quit_button.png"><br /><br />
     * <img src="patterns/AA/FailureToConnectToStorageDialog/quit_button_mouseover.png"><br /><br />
     * Text antialiasing disabled:<br />
     * <img src="patterns/noAA/FailureToConnectToStorageDialog/error_icon.png"><br /><br />
     * <img src="patterns/noAA/FailureToConnectToStorageDialog/configure_button.png"><br /><br />
     * <img src="patterns/noAA/FailureToConnectToStorageDialog/quit_button.png"><br /><br />
     * <img src="patterns/noAA/FailureToConnectToStorageDialog/quit_button_mouseover.png"><br /><br />
     *  
     * @param robot
     * @throws IOException
     */
    protected void checkForErrorIconAndClickQuit(GuiRobot robot) throws IOException
    {
        checkForPattern(robot, Patterns.FailureToConnectToStorageDialog.ERROR_ICON, "error icon");
        checkForPattern(robot, Patterns.FailureToConnectToStorageDialog.CONFIGURE_BUTTON, "configure button");
        Rectangle rectQuitButton = checkForPattern(robot, Patterns.FailureToConnectToStorageDialog.QUIT_BUTTON, "quit button");

        robot.clickToRectangle(rectQuitButton);
    }
   
    /**
     * Method testStartWithTomcatWithoutStorage
     * tries to start thermostat gui in new thread without previously
     * starting the storage, but with running tomcat. There will be no gui
     * running, because it connects to the web storage and wants some data
     * that are not reachable withouth the db.
     * There should also be some logs in the tomcat logs directory
     * about not being able to connect to the underlying mongodb.
     * 
     * This test uses the following scripts:
     * <ul>
     * <li><a href="scripts/list_all_therm_agents.sh">list_all_therm_agents.sh</a>,
     * <ul>
     *
     * Following patterns have been used:<br />
     * <img src="patterns/AA/FailureToConnectToStorageDialog/error_icon.png"><br /><br />
     * <img src="patterns/AA/FailureToConnectToStorageDialog/configure_button.png"><br /><br />
     * <img src="patterns/AA/FailureToConnectToStorageDialog/quit_button.png"><br /><br />
     * <img src="patterns/AA/FailureToConnectToStorageDialog/quit_button_mouseover.png"><br /><br />
     * Text antialiasing disabled:<br />
     * <img src="patterns/noAA/FailureToConnectToStorageDialog/error_icon.png"><br /><br />
     * <img src="patterns/noAA/FailureToConnectToStorageDialog/configure_button.png"><br /><br />
     * <img src="patterns/noAA/FailureToConnectToStorageDialog/quit_button.png"><br /><br />
     * <img src="patterns/noAA/FailureToConnectToStorageDialog/quit_button_mouseover.png"><br /><br />
     * 
     * @throws IOException
     * @throws AWTException 
     */
    public void testStartWithTomcatWithoutStorage() throws IOException, AWTException 
    {
        startTomcat();
        
        GuiRobot robot = new GuiRobot(this.configuration);

        if(this.configuration.useRealScreenshots())    
        {
            runThermostatGuiInANewThread();
            sleep(FIVE_SEC+3000);
        }
        robot.prepareScreenshot("FailureToConnectToWebStorageDialog01");
                
        checkForErrorIconAndClickQuit(robot);
        
        robot.saveScreenshot("FailureToConnectToWebStorageDialog02");
        
        stopTomcat();
        sleep(FIVE_SEC);
        
        //analyse the contents of logs in tomcat
        createTomcatThermostatOutputFiles();
        
        List<String> outputs = getTomcatOutputs("catalina-logs.txt");
        checkPresenceOfPatterns(outputs, thermGuiWithTomcatOnlyCatalinaLogs);
               
        outputs = getTomcatOutputs("thermostat-web-storage-logs.txt");
        checkPresenceOfPatterns(outputs, thermGuiWithTomcatOnlyThermostatLogs);
                
        outputs = getTomcatOutputs("localhost_access_logs.txt");
        
        listAgents();
    }
    
    /**
     * Method testStartWithStorageWithoutTomcat
     * tries to start thermostat gui in new thread without previously
     * starting tomcat, only the db is running. There should be no thermostat
     * gui running, because the gui connects to web storage.
     *
     * Following patterns have been used:<br />
     * <img src="patterns/AA/FailureToConnectToStorageDialog/error_icon.png"><br /><br />
     * <img src="patterns/AA/FailureToConnectToStorageDialog/configure_button.png"><br /><br />
     * <img src="patterns/AA/FailureToConnectToStorageDialog/quit_button.png"><br /><br />
     * <img src="patterns/AA/FailureToConnectToStorageDialog/quit_button_mouseover.png"><br /><br />
     * Text antialiasing disabled:<br />
     * <img src="patterns/noAA/FailureToConnectToStorageDialog/error_icon.png"><br /><br />
     * <img src="patterns/noAA/FailureToConnectToStorageDialog/configure_button.png"><br /><br />
     * <img src="patterns/noAA/FailureToConnectToStorageDialog/quit_button.png"><br /><br />
     * <img src="patterns/noAA/FailureToConnectToStorageDialog/quit_button_mouseover.png"><br /><br />
     * 
     * @throws IOException
     * @throws InterruptedException 
     * @throws AWTException 
     */
    public void testStartWithStorageWithoutTomcat() throws IOException, InterruptedException, AWTException
    {
        startStorage();
        
        GuiRobot robot = new GuiRobot(this.configuration);

        if (this.configuration.useRealScreenshots())
        {
            runThermostatGuiInANewThread();
            sleep(FIVE_SEC);
        }
        robot.prepareScreenshot("FailureToConnectToWebStorageDialog11");
        
        checkForErrorIconAndClickQuit(robot);

        robot.saveScreenshot("FailureToConnectToWebStorageDialog12");

        stopStorage();
    }
    
    /**
     * Method testStartGuiAndCheckTomcatLogs
     * starts the storage and then tries to start thermostat gui in a new
     * thread. The gui should start and we will check the tomcat logs.
     *  
     * Following patterns are checked for its presence:<br /><br />
     * Text antialiasing enabled:<br />
     * <img src="patterns/AA/MainWindow/magnify_icon.png"><br /><br />
     * <img src="patterns/AA/MainWindow/issues_label.png"><br /><br />
     * <img src="patterns/AA/MainWindow/summary_label.png"><br /><br />
     * <img src="patterns/AA/MainWindow/main_menu.png"><br /><br />
     * <img src="patterns/AA/MainMenu/menu_bar_file.png"><br /><br />
     * <img src="patterns/AA/MainMenu/menu_bar_edit.png"><br /><br />
     * <img src="patterns/AA/MainMenu/menu_bar_view.png"><br /><br />
     * <img src="patterns/AA/MainMenu/menu_bar_help.png"><br /><br />
     * Text antialiasing disabled:<br />
     * <img src="patterns/noAA/MainWindow/magnify_icon.png"><br /><br />
     * <img src="patterns/noAA/MainWindow/issues_label.png"><br /><br />
     * <img src="patterns/noAA/MainWindow/summary_label.png"><br /><br />
     * <img src="patterns/noAA/MainWindow/main_menu.png"><br /><br />
     * <img src="patterns/noAA/MainMenu/menu_bar_file.png"><br /><br />
     * <img src="patterns/noAA/MainMenu/menu_bar_edit.png"><br /><br />
     * <img src="patterns/noAA/MainMenu/menu_bar_view.png"><br /><br />
     * <img src="patterns/noAA/MainMenu/menu_bar_help.png"><br /><br />
     *  
     * @throws IOException
     * @throws AWTException 
     */
    @TillVersion("0.14.0")
    public void testStartGuiAndCheckTomcatLogs() throws IOException, AWTException
    {
        startWebStorage();

        sleep(FIVE_SEC);
        
        GuiRobot robot = new GuiRobot(this.configuration);

        if (this.configuration.useRealScreenshots())
        {
            runThermostatGuiInANewThread();
            sleep(FIVE_SEC);
        }
        robot.prepareScreenshot("GuiWithWebStorage1");
                
        //some time to let the logs appear - let us check the patterns meanwhile
        checkForPattern(robot, Patterns.MainWindow.MAGNIFY_ICON, "magnify icon");
        checkForPattern(robot, Patterns.MainWindow.ISSUES_LABEL, "issues label");
        checkForPattern(robot, Patterns.MainWindow.SUMMARY_LABEL, "summary label");
        checkForPattern(robot, Patterns.MainWindow.MAIN_MENU, "main menu");
        
        checkForPattern(robot, Patterns.MainWindowMenuBar.FILE_MENU, "file menu");
        checkForPattern(robot, Patterns.MainWindowMenuBar.EDIT_MENU, "edit menu");
        checkForPattern(robot, Patterns.MainWindowMenuBar.VIEW_MENU, "view menu");
        checkForPattern(robot, Patterns.MainWindowMenuBar.HELP_MENU, "help menu");
        
        stopGUI(robot);
        stopWebStorage();
        
        
        //analyse the contents of logs in tomcat
        createTomcatThermostatOutputFiles();
        
        List<String> outputs = getTomcatOutputs("catalina-logs.txt");
        //for(String s : outputs)
        //{
        //    logInfo("catalina-logs.txt", s);
        //}
                
        checkPresenceOfPatterns(outputs,thermGuiWithWebStorageCatalinaLogs);
        
        outputs = getTomcatOutputs("thermostat-web-storage-logs.txt");
        //for(String s : outputs)
        //{
        //    logInfo("thermostat-web-storage-logs.txt", s);
        //}
                
        checkPresenceOfPatterns(outputs,thermGuiWithWebStorageThermostatLogs);
        
        outputs = getTomcatOutputs("localhost_access_logs.txt");    
        //for(String s : outputs)
        //{
        //    logInfo("localhost_access_logs.txt", s);
        //}
      
      }
    
    /**
     * Method testStartGuiAndCheckTomcatLogs2
     * starts the storage and then tries to start thermostat gui in a new
     * thread. The gui should start and we will check the tomcat logs.
     *  
     * Following patterns are checked for its presence:<br /><br />
     * Text antialiasing enabled:<br />
     * <img src="patterns/AA/MainWindow/main_menu.png"><br /><br />
     * <img src="patterns/AA/MainMenu/menu_bar_file.png"><br /><br />
     * <img src="patterns/AA/MainMenu/menu_bar_edit.png"><br /><br />
     * <img src="patterns/AA/MainMenu/menu_bar_view.png"><br /><br />
     * <img src="patterns/AA/MainMenu/menu_bar_help.png"><br /><br />
     * Text antialiasing disabled:<br />
     * <img src="patterns/noAA/MainWindow/main_menu.png"><br /><br />
     * <img src="patterns/noAA/MainMenu/menu_bar_file.png"><br /><br />
     * <img src="patterns/noAA/MainMenu/menu_bar_edit.png"><br /><br />
     * <img src="patterns/noAA/MainMenu/menu_bar_view.png"><br /><br />
     * <img src="patterns/noAA/MainMenu/menu_bar_help.png"><br /><br />
     *  
     * @throws IOException
     * @throws AWTException 
     */
    @SinceVersion("0.16.0")
    public void testStartGuiAndCheckTomcatLogs2() throws IOException, AWTException
    {
        startWebStorage();

        sleep(FIVE_SEC);
        
        GuiRobot robot = new GuiRobot(this.configuration);

        if (this.configuration.useRealScreenshots())
        {
            runThermostatGuiInANewThread();
            sleep(7000);
        }
            robot.prepareScreenshot("GuiWithWebStorage1");
        
        //some time to let the logs appear - let us check the patterns meanwhile
        checkForPattern(robot, Patterns.MainWindow.MAIN_MENU, "main menu");
        
        checkForPattern(robot, Patterns.MainWindowMenuBar.FILE_MENU, "file menu");
        checkForPattern(robot, Patterns.MainWindowMenuBar.EDIT_MENU, "edit menu");
        checkForPattern(robot, Patterns.MainWindowMenuBar.VIEW_MENU, "view menu");
        checkForPattern(robot, Patterns.MainWindowMenuBar.HELP_MENU, "help menu");
        
        stopGUI(robot);
        stopWebStorage();
        
        
        //analyse the contents of logs in tomcat
        createTomcatThermostatOutputFiles();
        
        List<String> outputs = getTomcatOutputs("catalina-logs.txt");
        //for(String s : outputs)
        //{
        //    logInfo("catalina-logs.txt", s);
        //}
                
        checkPresenceOfPatterns(outputs,thermGuiWithWebStorageCatalinaLogs);
        
        outputs = getTomcatOutputs("thermostat-web-storage-logs.txt");
        //for(String s : outputs)
        //{
        //    logInfo("thermostat-web-storage-logs.txt", s);
        //}
                
        checkPresenceOfPatterns(outputs,thermGuiWithWebStorageThermostatLogs);
        
        outputs = getTomcatOutputs("localhost_access_logs.txt");    
        //for(String s : outputs)
        //{
        //    logInfo("localhost_access_logs.txt", s);
        //}
      
      }
    
    /**
     * Method testStartGuiWithBadLogin
     * starts the web storage and tries to connect a gui client with bad login.
     * The attempt should be logged in catalina.out as unsuccessful login.
     * 
     * Following patterns have been used:<br />
     * <img src="patterns/AA/FailureToConnectToStorageDialog/error_icon.png"><br /><br />
     * <img src="patterns/AA/FailureToConnectToStorageDialog/configure_button.png"><br /><br />
     * <img src="patterns/AA/FailureToConnectToStorageDialog/quit_button.png"><br /><br />
     * <img src="patterns/AA/FailureToConnectToStorageDialog/quit_button_mouseover.png"><br /><br />
     * Text antialiasing disabled:<br />
     * <img src="patterns/noAA/FailureToConnectToStorageDialog/error_icon.png"><br /><br />
     * <img src="patterns/noAA/FailureToConnectToStorageDialog/configure_button.png"><br /><br />
     * <img src="patterns/noAA/FailureToConnectToStorageDialog/quit_button.png"><br /><br />
     * <img src="patterns/noAA/FailureToConnectToStorageDialog/quit_button_mouseover.png"><br /><br />
     * 
     * @throws IOException
     * @throws AWTException 
     */
    public void testStartGuiWithBadLogin() throws IOException, AWTException{
        //copy bad login info into agent conf
        prepareWebStorageBadClientLoginFile();
        
        //try to run
        GuiRobot robot = startThermostatAndWebStorage();
        sleepIfRealScreen(3000);
        robot.prepareScreenshot("guiWSBadLogin");
        stopThermostatAndWebStorage(robot);
        checkForErrorIconAndClickQuit(robot);
        robot.saveScreenshot("guiWSBadLogin2");            
         
        //analyse the contents of logs in tomcat
        createTomcatThermostatOutputFiles();
        
        List<String> outputs = getTomcatOutputs("catalina-logs.txt");
        //for(String s : outputs)
        //{
        //    logInfo("Bad login catalina-logs.txt ", s);
        //}
        checkPresenceOfPatterns(outputs, thermGuiBadLoginCatalinaLogs);
        
        outputs = getTomcatOutputs("thermostat-web-storage-logs.txt");
        //for(String s : outputs)
        //{
        //    logInfo("Bad login thermostat-web-storage-logs.txt ", s);
        //}
        
        outputs = getTomcatOutputs("localhost_access_logs.txt");
        //for(String s : outputs)
        //{
        //    logInfo("Bad login localhost_access_logs.txt ", s);
        //}
        
        //copy back the good login info
        prepareWebStorageConfigFiles();
    }
    
    /**
     * Method testGuiFixBadLoginWebStorage
     * starts the web storage and tries to connect a gui client with bad login,
     * when the attempt fails, the configuration is changed and this time
     * it should succeed and start the gui.
     * The attempt should be logged in catalina.out as unsuccessful login.
     * (All the logs for successful start of web storage should be present too,
     * they are not checked yet.)
     * 
     * Following patterns have been used:<br />
     * <img src="patterns/AA/FailureToConnectToStorageDialog/error_icon.png"><br /><br />
     * <img src="patterns/AA/FailureToConnectToStorageDialog/configure_button.png"><br /><br />
     * <img src="patterns/AA/FailureToConnectToStorageDialog/quit_button.png"><br /><br />
     * <img src="patterns/AA/FailureToConnectToStorageDialog/quit_button_mouseover.png"><br /><br />
     * <img src="patterns/AA/MainWindow/magnify_icon.png"><br /><br />
     * <img src="patterns/AA/MainWindow/issues_label.png"><br /><br />
     * <img src="patterns/AA/MainWindow/summary_label.png"><br /><br />
     * <img src="patterns/AA/MainWindow/main_menu.png"><br /><br />
     * <img src="patterns/AA/MainMenu/menu_bar_file.png"><br /><br />
     * <img src="patterns/AA/MainMenu/menu_bar_edit.png"><br /><br />
     * <img src="patterns/AA/MainMenu/menu_bar_view.png"><br /><br />
     * <img src="patterns/AA/MainMenu/menu_bar_help.png"><br /><br />
     * Text antialiasing disabled:<br />
     * <img src="patterns/noAA/FailureToConnectToStorageDialog/error_icon.png"><br /><br />
     * <img src="patterns/noAA/FailureToConnectToStorageDialog/configure_button.png"><br /><br />
     * <img src="patterns/noAA/FailureToConnectToStorageDialog/quit_button.png"><br /><br />
     * <img src="patterns/noAA/FailureToConnectToStorageDialog/quit_button_mouseover.png"><br /><br />
     * <img src="patterns/noAA/MainWindow/magnify_icon.png"><br /><br />
     * <img src="patterns/noAA/MainWindow/issues_label.png"><br /><br />
     * <img src="patterns/noAA/MainWindow/summary_label.png"><br /><br />
     * <img src="patterns/noAA/MainWindow/main_menu.png"><br /><br />
     * <img src="patterns/noAA/MainMenu/menu_bar_file.png"><br /><br />
     * <img src="patterns/noAA/MainMenu/menu_bar_edit.png"><br /><br />
     * <img src="patterns/noAA/MainMenu/menu_bar_view.png"><br /><br />
     * <img src="patterns/noAA/MainMenu/menu_bar_help.png"><br /><br />
     * 
     * @throws IOException
     * @throws AWTException 
     */
    public void testGuiFixBadLoginWebStorage() throws IOException, AWTException{
        //copy bad login info into agent conf
        prepareWebStorageBadClientLoginFile();
        
        //try to run
        GuiRobot robot = startThermostatAndWebStorage();
        sleepIfRealScreen(3000);
        prepareScreenshot(robot, "guiWSBadLogin");
        
        //find "configuration"
        Rectangle rectConfigureButton = checkForPattern(robot, Patterns.FailureToConnectToStorageDialog.CONFIGURE_BUTTON, "configure button");
        robot.clickToRectangle(rectConfigureButton);
        
        sleepIfRealScreen(3000);
        prepareScreenshot(robot, "guiWSConfigure");
        
        //find editing dialog
        checkForPattern(robot, Patterns.ClientPreferencesDialog.WEB_STORAGE_CONNECTION_INFO, "web storage connection info");
        Rectangle rectUserNameEdit = checkForPattern(robot, Patterns.ClientPreferencesDialog.BAD_LOGIN_USER_NAME, "user name");
        //click username
        //edit
        robot.clickToRectangle(rectUserNameEdit);
        robot.clickToRectangle(rectUserNameEdit);
        robot.writeSmallLettersText("client");
        robot.writeSpecialChar('-');
        robot.writeSmallLettersText("tester");
                
        Rectangle rectPasswordEdit = checkForPattern(robot, Patterns.ClientPreferencesDialog.PASSWORD_EDIT_AND_LABEL, "password edit");
        //click password
        //edit
        robot.clickToRectangle(rectPasswordEdit);
        robot.clickToRectangle(rectPasswordEdit);
        robot.writeSmallLettersText("heslo");
        robot.writeNumbersText("2");
        
        Rectangle rectOkButton = checkForPattern(robot, Patterns.ClientPreferencesDialog.OK_BUTTON, "client preferences ok button");
        //click ok
        robot.clickToRectangle(rectOkButton);
        
        //gui should appear ... wait, create screenshot, check patterns
        sleepIfRealScreen(7000);
        robot.prepareScreenshot("guiWSFixedLogin");

        //check that the gui appeared (at least most of it...)
        checkForPattern(robot, Patterns.MainWindow.MAIN_MENU, "main menu");
        
        checkForPattern(robot, Patterns.MainWindowMenuBar.FILE_MENU, "file menu");
        checkForPattern(robot, Patterns.MainWindowMenuBar.EDIT_MENU, "edit menu");
        checkForPattern(robot, Patterns.MainWindowMenuBar.VIEW_MENU, "view menu");
        checkForPattern(robot, Patterns.MainWindowMenuBar.HELP_MENU, "help menu");
        
        stopThermostatAndWebStorage(robot);
        sleep(3000);//do not disturb the sleeping storage
         
        //analyse the contents of logs in tomcat
        createTomcatThermostatOutputFiles();
        
        List<String> outputs = getTomcatOutputs("catalina-logs.txt");
        //for(String s : outputs)
        //{
        //    logInfo("Bad login catalina-logs.txt ", s);
        //}
        checkPresenceOfPatterns(outputs, thermGuiBadLoginCatalinaLogs);
        checkPresenceOfPatterns(outputs, thermGuiWithWebStorageCatalinaLogs);
        
        outputs = getTomcatOutputs("thermostat-web-storage-logs.txt");
        //for(String s : outputs)
        //{
        //    logInfo("Bad login thermostat-web-storage-logs.txt ", s);
        //}
        checkPresenceOfPatterns(outputs, thermGuiWithWebStorageThermostatLogs);
        
        outputs = getTomcatOutputs("localhost_access_logs.txt");
        //for(String s : outputs)
        //{
        //    logInfo("Bad login localhost_access_logs.txt ", s);
        //}
        
        //copy back the good login info
        prepareWebStorageConfigFiles();
    }
    
    
    /**
     * Test if "Failure dialog" is displayed when Thermostat GUI client is started
     * w/o storage.
     *
     * Following patterns are checked for its presence:<br /><br />
     * Text antialiasing enabled:<br />
     * <img src="patterns/AA/FailureToConnectToStorageDialog/error_icon.png"><br /><br />
     * <img src="patterns/AA/FailureToConnectToStorageDialog/configure_button.png"><br /><br />
     * <img src="patterns/AA/FailureToConnectToStorageDialog/quit_button.png"><br /><br />
     * Text antialiasing disabled:<br />
     * <img src="patterns/noAA/FailureToConnectToStorageDialog/error_icon.png"><br /><br />
     * <img src="patterns/noAA/FailureToConnectToStorageDialog/configure_button.png"><br /><br />
     * <img src="patterns/noAA/FailureToConnectToStorageDialog/quit_button.png"><br /><br />
     * 
     * @throws IOException
     * @throws AWTException
     */
    public void testStartGUIWithoutWebStorage() throws IOException, AWTException
    {
        GuiRobot robot = new GuiRobot(this.configuration);

        if (this.configuration.useRealScreenshots())
        {
            runThermostatGuiInANewThread();
            sleep(FIVE_SEC);
        }
        
        robot.prepareScreenshot("FailureToConnectToWebStorageDialog1");

        checkForErrorIconAndClickQuit(robot);
        robot.saveScreenshot("FailureToConnectToWebStorageDialog2");
    }

    /**
     * Test if all base GUI parts are displayed on the screen when Thermostat GUI client
     * is started with web storage.
     *
     * Following patterns are checked for its presence:<br /><br />
     * Text antialiasing enabled:<br />
     * <img src="patterns/AA/MainWindow/magnify_icon.png"><br /><br />
     * <img src="patterns/AA/MainWindow/issues_label.png"><br /><br />
     * <img src="patterns/AA/MainWindow/summary_label.png"><br /><br />
     * <img src="patterns/AA/MainWindow/main_menu.png"><br /><br />
     * Text antialiasing disabled:<br />
     * <img src="patterns/noAA/MainWindow/magnify_icon.png"><br /><br />
     * <img src="patterns/noAA/MainWindow/issues_label.png"><br /><br />
     * <img src="patterns/noAA/MainWindow/summary_label.png"><br /><br />
     * <img src="patterns/noAA/MainWindow/main_menu.png"><br /><br />
     *
     * @throws IOException
     * @throws AWTException
     */
    @TillVersion("0.14.0")
    public void testStartGUIWithWebStorageBasicTest() throws IOException, AWTException
    {
        GuiRobot robot = startThermostatAndWebStorage();
        sleepIfRealScreen(3000);
        prepareScreenshot(robot, "testStartGUIWithWebStorageBasicTest1");

        checkForPattern(robot, Patterns.MainWindow.MAGNIFY_ICON, "magnify icon");
        checkForPattern(robot, Patterns.MainWindow.ISSUES_LABEL, "issues label");
        checkForPattern(robot, Patterns.MainWindow.SUMMARY_LABEL, "summary label");
        checkForPattern(robot, Patterns.MainWindow.MAIN_MENU, "main menu");

        robot.saveScreenshot("testStartGUIWithWebStorageBasicTest2");

        stopThermostatAndWebStorage(robot);
    }

    /**
     * Test for presence of all four main menu items when gui is started
     * with web storage: File menu, Edit menu, View menu and Help menu.
     *
     * Following patterns are checked for its presence:<br /><br />
     * Text antialiasing enabled:<br />
     * <img src="patterns/AA/MainMenu/menu_bar_file.png"><br /><br />
     * <img src="patterns/AA/MainMenu/menu_bar_edit.png"><br /><br />
     * <img src="patterns/AA/MainMenu/menu_bar_view.png"><br /><br />
     * <img src="patterns/AA/MainMenu/menu_bar_help.png"><br /><br />
     * Text antialiasing disabled:<br />
     * <img src="patterns/noAA/MainMenu/menu_bar_file.png"><br /><br />
     * <img src="patterns/noAA/MainMenu/menu_bar_edit.png"><br /><br />
     * <img src="patterns/noAA/MainMenu/menu_bar_view.png"><br /><br />
     * <img src="patterns/noAA/MainMenu/menu_bar_help.png"><br /><br />
     *
     * @throws IOException
     * @throws AWTException
     */
    public void testStartGUIWithWebStorageMenuTest() throws IOException, AWTException
    {
        GuiRobot robot = startThermostatAndWebStorage();
        sleepIfRealScreen(FIVE_SEC);
        prepareScreenshot(robot, "testStartGUIWithWebStorageMenuTest1");

        checkForPattern(robot, Patterns.MainWindowMenuBar.FILE_MENU, "file menu");
        checkForPattern(robot, Patterns.MainWindowMenuBar.EDIT_MENU, "edit menu");
        checkForPattern(robot, Patterns.MainWindowMenuBar.VIEW_MENU, "view menu");
        checkForPattern(robot, Patterns.MainWindowMenuBar.HELP_MENU, "help menu");

        robot.saveScreenshot("testStartGUIWithWebStorageMenuTest2");

        stopThermostatAndWebStorage(robot);
    }

    /**
     * Test if Summary tab is shown on the screen when gui is started
     * with web storage.
     *
     * Following patterns are checked for its presence:<br /><br />
     * Text antialiasing enabled:<br />
     * <img src="patterns/AA/TabSummary/summary_label.png"><br /><br />
     * <img src="patterns/AA/TabSummary/issues_label.png"><br /><br />
     * <img src="patterns/AA/TabSummary/total_machines_label.png"><br /><br />
     * <img src="patterns/AA/TabSummary/total_java_virtual_machines_label.png"><br /><br />
     * <img src="patterns/AA/TabSummary/no_issues_in_text_area.png"><br /><br />
     * Text antialiasing disabled:<br />
     * <img src="patterns/noAA/TabSummary/summary_label.png"><br /><br />
     * <img src="patterns/noAA/TabSummary/issues_label.png"><br /><br />
     * <img src="patterns/noAA/TabSummary/total_machines_label.png"><br /><br />
     * <img src="patterns/noAA/TabSummary/total_java_virtual_machines_label.png"><br /><br />
     * <img src="patterns/noAA/TabSummary/no_issues_in_text_area.png"><br /><br />
     * 
     * @throws IOException
     * @throws AWTException
     */
    @TillVersion("0.14.0")
    public void testSummaryTab() throws IOException, AWTException
    {
        GuiRobot robot = startThermostatAndWebStorage();
        sleepIfRealScreen(3000);
        prepareScreenshot(robot, "testSummaryTabWSTest1");

        checkForPattern(robot, Patterns.SummaryTab.SUMMARY_LABEL, "summary label on summary tab");
        checkForPattern(robot, Patterns.SummaryTab.TOTAL_MACHINES_LABEL, "total machines label on summary tab");
        checkForPattern(robot, Patterns.SummaryTab.TOTAL_VIRTUAL_MACHINES_LABEL, "total virtual machines label on summary tab");
        checkForPattern(robot, Patterns.SummaryTab.ISSUES_LABEL, "issues label on summary tab");
        checkForPattern(robot, Patterns.SummaryTab.NO_ISSUES_IN_TEXT_AREA, "'no issues' text placed in text area");

        robot.saveScreenshot("testSummaryTabWSTest2");
        stopThermostatAndWebStorage(robot);
    }

    /**
     * Test if dialog with client preferences is really shown on the screen,
     * when gui is started with web storage.
     *
     * Following patterns are checked for its presence:<br /><br />
     * Text antialiasing enabled:<br />
     * <img src="patterns/AA/ClientPreferencesDialog/ok_button.png"><br /><br />
     * <img src="patterns/AA/ClientPreferencesDialog/cancel_button.png"><br /><br />
     * <img src="patterns/AA/ClientPreferencesDialog/user_name_label.png"><br /><br />
     * <img src="patterns/AA/ClientPreferencesDialog/password_label.png"><br /><br />
     * <img src="patterns/AA/ClientPreferencesDialog/storage_url_label.png"><br /><br />
     * <img src="patterns/AA/ClientPreferencesDialog/web_storage_connection_info_label.png"><br /><br />
     * <img src="patterns/AA/ClientPreferencesDialog/save_entitlements_checked.png"><br /><br />
     * Text antialiasing disabled:<br />
     * <img src="patterns/noAA/ClientPreferencesDialog/ok_button.png"><br /><br />
     * <img src="patterns/noAA/ClientPreferencesDialog/cancel_button.png"><br /><br />
     * <img src="patterns/noAA/ClientPreferencesDialog/user_name_label.png"><br /><br />
     * <img src="patterns/noAA/ClientPreferencesDialog/password_label.png"><br /><br />
     * <img src="patterns/noAA/ClientPreferencesDialog/storage_url_label.png"><br /><br />
     * <img src="patterns/noAA/ClientPreferencesDialog/web_storage_connection_info_label.png"><br /><br />
     * <img src="patterns/noAA/ClientPreferencesDialog/save_entitlements_checked.png"><br /><br />
     * 
     * @throws IOException
     * @throws AWTException
     */
    public void testEditClientPreferences() throws IOException, AWTException
    {
        GuiRobot robot = startThermostatAndWebStorage();

        sleepIfRealScreen(FIVE_SEC);
        
        enterMainMenu(robot);
        robot.pressRightKey();
        robot.pressDownKey();
        robot.pressEnterKey();
        sleepIfRealScreen(ONE_SEC);

        prepareScreenshot(robot, "testEditClientPreferencesWSTest1");

        robot.pressEnterKey();
        stopThermostatAndWebStorage(robot);

        checkForPattern(robot, Patterns.ClientPreferencesDialog.OK_BUTTON, "ok button");
        checkForPattern(robot, Patterns.ClientPreferencesDialog.CANCEL_BUTTON, "cancel button");
        checkForPattern(robot, Patterns.ClientPreferencesDialog.WEB_STORAGE_CONNECTION_INFO, "connection info text on dialog");
        checkForPattern(robot, Patterns.ClientPreferencesDialog.USER_NAME_LABEL, "user name label");
        checkForPattern(robot, Patterns.ClientPreferencesDialog.PASSWORD_LABEL, "password label");
        checkForPattern(robot, Patterns.ClientPreferencesDialog.STORAGE_URL_LABEL, "storage url label");
        checkForPattern(robot, Patterns.ClientPreferencesDialog.SAVE_ENTITLEMENTS_CHECKED, "save entitlements checkbox");
        robot.saveScreenshot("testEditClientPreferencesWSTest2");
    }    
    
    public static void main(String[] args) {
        new GuiClientWebStorageTest().doTests(args);
    }

}