changeset 199:0351a5e0ca27

Added Gui runner This adds new makefile target for running Thermostat gui. (with agent) It makes running Thermostat gui easier compared to running it manualy (for manual experimenting/testing). Same code as for running tests is used. It acts like dummy test where no testing is done and testsuite waits until user closes window. Its class is in separate package so it is not executed with other tests. Changes: org.thermostat.qa2.tests.dummy.GuiRunner: - new dummy test class used to run gui Makefile: - added new target run-gui, which starts gui (using dummy test class) org.thermostat.qa2.framework.services.AbstractService: - added method to wait until service (e.g. gui) finishes org.thermostat.qa2.framework.services.ThermostatFullStorage - stopping sub services in case of webstorage changed to natural order in this compound service
author Zdenek Zambersky <zzambers@redhat.com>
date Wed, 12 Aug 2015 12:51:40 +0200
parents 085c86ddaeed
children 1af19d2e7271
files Makefile src/org/thermostat/qa2/framework/services/AbstractService.java src/org/thermostat/qa2/framework/services/ThermostatFullStorage.java src/org/thermostat/qa2/tests/dummy/GuiRunner.java
diffstat 4 files changed, 94 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile	Tue Aug 11 19:41:59 2015 +0200
+++ b/Makefile	Wed Aug 12 12:51:40 2015 +0200
@@ -161,6 +161,23 @@
 	-Dgnome-keyring.config.dir=$(GNOME_KEYRING_USER_DATA_DIR) \
 	-Dbackup.dir=$(BUILD_DIR)/backup \
 	org.thermostat.qa2.framework.TestRunner org.thermostat.qa2.tests.compatibility.$@ 2>&1 | tee $(LOGS_DIR)/compatibility/$(THERMOSTAT_OTHER_VERSION)/$(DATE)/$@.log
+	
+.PHONY: run-gui
+run-gui: build thermostat-build testwarning checkdeps | $(GNOME_KEYRING_USER_DATA_DIR)
+	killall mongod &> /dev/null || true
+	killall gnome-keyring-daemon &> /dev/null || true
+	mkdir -p $(BUILD_DIR)/backup
+	USER_THERMOSTAT_HOME=$(THERMOSTAT_USER_DIR) \
+	$(JAVA) -cp $(CLASSES_DIR) \
+	-Dthermostat.user.home=$(THERMOSTAT_USER_DIR) \
+	-Dthermostat.version=$(THERMOSTAT_VERSION) \
+	-Dthermostat.home=$(THERMOSTAT_HOME_DIR) \
+	-Dthermostat.packaged=$(THERMOSTAT_PACKAGED) \
+	-Dthermostat.webstorage.port=$(THERMOSTAT_WEBSTORAGE_PORT) \
+	-Dtomcat.home=$(TOMCAT_DIR) \
+	-Dgnome-keyring.config.dir=$(GNOME_KEYRING_USER_DATA_DIR) \
+	-Dbackup.dir=$(BUILD_DIR)/backup \
+	org.thermostat.qa2.framework.TestRunner org.thermostat.qa2.tests.dummy.GuiRunner
 
 .PHONY: testwarning
 testwarning:
--- a/src/org/thermostat/qa2/framework/services/AbstractService.java	Tue Aug 11 19:41:59 2015 +0200
+++ b/src/org/thermostat/qa2/framework/services/AbstractService.java	Wed Aug 12 12:51:40 2015 +0200
@@ -59,6 +59,15 @@
     protected void setRunning(boolean running) {
         synchronized (lock) {
             isRunning = running;
+            lock.notifyAll();
+        }
+    }
+
+    public void waitFor() throws Exception {
+        synchronized (lock) {
+            while (isRunning) {
+                lock.wait();
+            }
         }
     }
 
--- a/src/org/thermostat/qa2/framework/services/ThermostatFullStorage.java	Tue Aug 11 19:41:59 2015 +0200
+++ b/src/org/thermostat/qa2/framework/services/ThermostatFullStorage.java	Wed Aug 12 12:51:40 2015 +0200
@@ -69,12 +69,12 @@
 
     @Override
     public void stopServiceImpl() throws Exception {
+        if (web && tomcat.isRunning()) {
+            tomcat.stop();
+        }
         if (storage.isRunning()) {
             storage.stop();
         }
-        if (web && tomcat.isRunning()) {
-            tomcat.stop();
-        }
         setRunning(false);
     }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/thermostat/qa2/tests/dummy/GuiRunner.java	Wed Aug 12 12:51:40 2015 +0200
@@ -0,0 +1,65 @@
+/*
+ ThermostatQA - test framework for Thermostat Monitoring Tool
+
+ Copyright 2015 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.qa2.tests.dummy;
+
+import org.thermostat.qa2.framework.annotations.RunGnomeKeyring;
+import org.thermostat.qa2.framework.annotations.SetupStorage;
+import org.thermostat.qa2.framework.annotations.Test;
+import org.thermostat.qa2.framework.services.ThermostatAgent;
+import org.thermostat.qa2.framework.services.ThermostatFullStorage;
+import org.thermostat.qa2.framework.services.ThermostatGui;
+
+/**
+ *
+ * @author Zdeněk Žamberský
+ */
+public class GuiRunner {
+
+    @Test
+    @RunGnomeKeyring
+    @SetupStorage(type = "mongo")
+    public void runGui() throws Exception {
+        ThermostatFullStorage storage = new ThermostatFullStorage();
+        storage.start();
+
+        ThermostatAgent agent = new ThermostatAgent();
+        agent.start();
+        
+        ThermostatGui gui = new ThermostatGui();
+        gui.start();
+        // user is expected to close the application
+        gui.waitFor();
+        
+        agent.stop();
+        storage.stop();
+    }
+
+}