Mercurial > hg > ThermostatQA
view src/org/thermostat/qa2/tests/SmokeTests.java @ 204:1b447165fbd0
enabled collection where missing
author | Zdenek Zambersky <zzambers@redhat.com> |
---|---|
date | Mon, 07 Dec 2015 18:31:50 +0100 |
parents | 1d7ab9111fd2 |
children |
line wrap: on
line source
/* 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; import java.io.File; import java.io.IOException; import java.util.List; import static org.thermostat.qa2.framework.Assert.assertTrue; import org.thermostat.qa2.framework.NativeProcess; import org.thermostat.qa2.framework.ThermostatQAConfig; import org.thermostat.qa2.framework.annotations.SetupThermostat; import org.thermostat.qa2.framework.annotations.Test; import org.thermostat.qa2.framework.utils.ProcessUtilities; import org.thermostat.qa2.framework.utils.ThermostatUtilities; /** * Test class ported from old framework * * @author Zdeněk Žamberský */ @SetupThermostat public class SmokeTests { @Test public void checkPatchToThermostatExecutable() { String path = ThermostatQAConfig.getThermostatExecutablePath(); File f = new File(path); assertTrue(f.exists(), path + " does not exist"); } @Test public void checkIfThermostatExecutableCanBeRead() { String path = ThermostatQAConfig.getThermostatExecutablePath(); File f = new File(path); assertTrue(f.canRead(), path + " is not readable"); } @Test public void checkIfThermostatExecutableCanBeExecuted() { String path = ThermostatQAConfig.getThermostatExecutablePath(); File f = new File(path); assertTrue(f.canExecute(), path + " is not executable"); } @Test public void tryToRunThermostatExecutable() throws IOException, InterruptedException { ProcessUtilities.runRaw(ThermostatUtilities.getThermostatCommandLine(new String[]{})); } @Test public void checkExitValue() throws IOException, InterruptedException { int exitValue = ProcessUtilities.runRaw(ThermostatUtilities.getThermostatCommandLine(new String[]{})); assertTrue(exitValue == 0, "thermostat returned non-zero value"); } @Test public void checkStandardMessage() throws IOException, Exception { NativeProcess process = new NativeProcess(ThermostatUtilities.getThermostatCommandLine(new String[]{})); process.setEnvironmentVariable("USER_THERMOSTAT_HOME", ThermostatQAConfig.getThermostatUserHome()); process.setStdOutMode(NativeProcess.MODE_LOG_AND_BUFFER); process.start(); process.waitFor(); List<String> processOutput = process.getStdoutLines(); assertTrue(processOutput.size() > 0, "no output from process"); } }