summaryrefslogtreecommitdiff
path: root/qadevOOo/runner
diff options
context:
space:
mode:
Diffstat (limited to 'qadevOOo/runner')
-rw-r--r--qadevOOo/runner/complexlib/Assurance.java25
-rw-r--r--qadevOOo/runner/graphical/EnhancedComplexTestCase.java23
-rw-r--r--qadevOOo/runner/graphical/JPEGCreator.java3
-rw-r--r--qadevOOo/runner/graphical/JPEGEvaluator.java2
-rw-r--r--qadevOOo/runner/graphical/Office.java1
-rw-r--r--qadevOOo/runner/graphical/OpenOfficeDatabaseReportExtractor.java21
-rw-r--r--qadevOOo/runner/graphical/OpenOfficePostscriptCreator.java3
-rw-r--r--qadevOOo/runner/graphical/ParameterHelper.java3
-rw-r--r--qadevOOo/runner/graphical/PostscriptCreator.java3
-rw-r--r--qadevOOo/runner/helper/OfficeProvider.java6
-rw-r--r--qadevOOo/runner/helper/ProcessHandler.java210
-rw-r--r--qadevOOo/runner/org/openoffice/Runner.java2
-rw-r--r--qadevOOo/runner/stats/Summarizer.java2
13 files changed, 268 insertions, 36 deletions
diff --git a/qadevOOo/runner/complexlib/Assurance.java b/qadevOOo/runner/complexlib/Assurance.java
index b07c3fb8b..844f70290 100644
--- a/qadevOOo/runner/complexlib/Assurance.java
+++ b/qadevOOo/runner/complexlib/Assurance.java
@@ -75,7 +75,7 @@ public class Assurance
* @param actual specifies the actual boolean value
*/
protected void assureEquals( boolean expected, boolean actual ) {
- assureEquals( "Equality test failed", new Boolean( expected ), new Boolean( actual ), false );
+ assureEquals( "Equality test failed", expected, new Boolean( actual ), false );
}
/**
@@ -85,7 +85,7 @@ public class Assurance
* @param actual specifies the actual boolean value
*/
protected void assureEquals( String message, boolean expected, boolean actual ) {
- assureEquals( message, new Boolean( expected ), new Boolean( actual ), false );
+ assureEquals( message, expected, actual, false );
}
/**
@@ -240,6 +240,27 @@ public class Assurance
assureEquals( message, expected, actual, false );
}
+ /**
+ * assures the two given sequences are of equal length, and have equal content
+ */
+ public <T> void assureEquals( String i_message, T[] i_expected, T[] i_actual, boolean i_continue )
+ {
+ if ( i_expected.length != i_actual.length )
+ failed( i_message + ": expected element count: " + i_expected.length + ", actual element count: " + i_actual.length );
+ for ( int i=0; i<i_expected.length; ++i )
+ {
+ assureEquals( i_message + ": mismatch at element pos " + i, i_expected[i], i_actual[i], i_continue );
+ }
+ }
+
+ /**
+ * assures the two given sequences are of equal length, and have equal content
+ */
+ public <T> void assureEquals( String i_message, T[] i_expected, T[] i_actual )
+ {
+ assureEquals( i_message, i_expected, i_actual, false );
+ }
+
/** invokes a given method on a given object, and assures a certain exception is caught
* @param _message is the message to print when the check fails
* @param _object is the object to invoke the method on
diff --git a/qadevOOo/runner/graphical/EnhancedComplexTestCase.java b/qadevOOo/runner/graphical/EnhancedComplexTestCase.java
index 020016111..2905e0d6b 100644
--- a/qadevOOo/runner/graphical/EnhancedComplexTestCase.java
+++ b/qadevOOo/runner/graphical/EnhancedComplexTestCase.java
@@ -45,7 +45,7 @@ abstract public class EnhancedComplexTestCase extends ComplexTestCase implements
private void callEntry(String _sEntry, ParameterHelper _aParam)
{
// log.println("- next file is: ------------------------------");
- log.println("File: " + _sEntry);
+ log.println(" File: " + _sEntry);
// TODO: check if 'sEntry' is a guilty document.
File aFile = new File(_aParam.getInputPath());
String sPath = _aParam.getInputPath();
@@ -254,8 +254,15 @@ private void callEntry(String _sEntry, ParameterHelper _aParam)
for (int i=0;i<aList.size();i++)
{
String sEntry = aList.get(i);
- callEntry(sEntry, _aParam);
-
+ try
+ {
+ callEntry(sEntry, _aParam);
+ }
+ catch (AssureException e)
+ {
+ // we only need to catch the assure()
+ // nOkStatus += 2;
+ }
// we want to know the current status of the run through
// if the status is greater (more bad) then the current,
// we will remember this. Only the very bad status will
@@ -469,9 +476,13 @@ private void callEntry(String _sEntry, ParameterHelper _aParam)
{
String sPSFile = aList.get(i);
- // TODO: this information has to come out of the ini files
- String sStatusRunThrough = "";
- String sStatusMessage = "";
+ // Read information out of the ini files
+ String sIndexFile2 = FileHelper.appendPath(sPath, sPSFile + ".ini");
+ IniFile aIniFile2 = new IniFile(sIndexFile2);
+ String sStatusRunThrough = aIniFile2.getValue("global", "state");
+ String sStatusMessage = ""; // aIniFile2.getValue("global", "info");
+ aIniFile2.close();
+
String sHTMLFile = sPSFile + ".html";
aOutputter.indexLine(sHTMLFile, sPSFile, sStatusRunThrough, sStatusMessage);
diff --git a/qadevOOo/runner/graphical/JPEGCreator.java b/qadevOOo/runner/graphical/JPEGCreator.java
index 922af500e..e5eda3fc3 100644
--- a/qadevOOo/runner/graphical/JPEGCreator.java
+++ b/qadevOOo/runner/graphical/JPEGCreator.java
@@ -61,7 +61,8 @@ public class JPEGCreator extends EnhancedComplexTestCase
public void checkOneFile(String _sDocumentName, String _sResult, ParameterHelper _aParams) throws OfficeException
{
- GlobalLogWriter.println("Document: " + _sDocumentName + " results: " + _sResult);
+ GlobalLogWriter.println(" Document: " + _sDocumentName);
+ GlobalLogWriter.println(" results: " + _sResult);
// IOffice aOffice = new Office(_aParams, _sResult);
// aOffice.start();
// aOffice.load(_sDocumentName);
diff --git a/qadevOOo/runner/graphical/JPEGEvaluator.java b/qadevOOo/runner/graphical/JPEGEvaluator.java
index c7de83cc0..51cc9687f 100644
--- a/qadevOOo/runner/graphical/JPEGEvaluator.java
+++ b/qadevOOo/runner/graphical/JPEGEvaluator.java
@@ -50,6 +50,8 @@ public class JPEGEvaluator extends EnhancedComplexTestCase
{
GlobalLogWriter.set(log);
ParameterHelper aParam = new ParameterHelper(param);
+
+ // aParam.getTestParameters().put("current_ok_status", -1);
// run through all documents found in Inputpath
foreachResultCreateHTML(aParam);
diff --git a/qadevOOo/runner/graphical/Office.java b/qadevOOo/runner/graphical/Office.java
index 23bd040cf..71e118d62 100644
--- a/qadevOOo/runner/graphical/Office.java
+++ b/qadevOOo/runner/graphical/Office.java
@@ -48,6 +48,7 @@ public class Office implements IOffice
m_sResult = _sResult;
if (_aParam.getReferenceType().toLowerCase().equals("ooo") ||
+ _aParam.getReferenceType().toLowerCase().equals("o3") ||
_aParam.getReferenceType().toLowerCase().equals("ps") ||
_aParam.getReferenceType().toLowerCase().equals("pdf"))
{
diff --git a/qadevOOo/runner/graphical/OpenOfficeDatabaseReportExtractor.java b/qadevOOo/runner/graphical/OpenOfficeDatabaseReportExtractor.java
index 2ddd33567..684e752b7 100644
--- a/qadevOOo/runner/graphical/OpenOfficeDatabaseReportExtractor.java
+++ b/qadevOOo/runner/graphical/OpenOfficeDatabaseReportExtractor.java
@@ -373,13 +373,20 @@ public class OpenOfficeDatabaseReportExtractor extends Assurance
{
String sReportName = sElementNames[i];
XComponent xDoc = loadComponent(sReportName, _xNameAccess, _aPropertyList);
-// util.utils.shortWait(1000);
- // print? or store?
- String sDocumentPathName = storeComponent(sReportName, xDoc /*, _nType*/);
- aList.add(sDocumentPathName);
-// util.utils.shortWait(1000);
- closeComponent(xDoc);
-// util.utils.shortWait(1000);
+ if (xDoc != null)
+ {
+ // util.utils.shortWait(1000);
+ // print? or store?
+ String sDocumentPathName = storeComponent(sReportName, xDoc /*, _nType*/);
+ aList.add(sDocumentPathName);
+ // util.utils.shortWait(1000);
+ closeComponent(xDoc);
+ // util.utils.shortWait(1000);
+ }
+ else
+ {
+ System.out.println("Leave out maybe due to errors.");
+ }
// sBackPath contains the path where to find the extracted ODB Document
}
}
diff --git a/qadevOOo/runner/graphical/OpenOfficePostscriptCreator.java b/qadevOOo/runner/graphical/OpenOfficePostscriptCreator.java
index 077ee4bd0..60fff9ba0 100644
--- a/qadevOOo/runner/graphical/OpenOfficePostscriptCreator.java
+++ b/qadevOOo/runner/graphical/OpenOfficePostscriptCreator.java
@@ -102,6 +102,7 @@ public class OpenOfficePostscriptCreator implements IOffice
{
String sDocumentName = FileHelper.appendPath(m_sOutputURL, m_sBasename);
if (m_aParameterHelper.getReferenceType().toLowerCase().equals("ooo") ||
+ m_aParameterHelper.getReferenceType().toLowerCase().equals("o3") ||
m_aParameterHelper.getReferenceType().toLowerCase().equals("ps") )
{
String sPrintURL = sDocumentName + ".ps";
@@ -1380,9 +1381,9 @@ public class OpenOfficePostscriptCreator implements IOffice
// Watcher Object is need in log object to give a simple way to say if a running office is alive.
// As long as a log comes, it pings the Watcher and says the office is alive, if not an
// internal counter increase and at a given point (300 seconds) the office is killed.
- GlobalLogWriter.println("Set office watcher");
if (GlobalLogWriter.get().getWatcher() == null)
{
+ GlobalLogWriter.println("Set office watcher");
OfficeWatcher aWatcher = (OfficeWatcher)m_aParameterHelper.getTestParameters().get("Watcher");
GlobalLogWriter.get().setWatcher(aWatcher);
}
diff --git a/qadevOOo/runner/graphical/ParameterHelper.java b/qadevOOo/runner/graphical/ParameterHelper.java
index 2450ce97c..3ae12bddc 100644
--- a/qadevOOo/runner/graphical/ParameterHelper.java
+++ b/qadevOOo/runner/graphical/ParameterHelper.java
@@ -267,7 +267,8 @@ public class ParameterHelper
// check if MultiServiceFactory is given
if (getReferenceType().toLowerCase().equals("pdf") ||
getReferenceType().toLowerCase().equals("ps") ||
- getReferenceType().toLowerCase().equals("ooo"))
+ getReferenceType().toLowerCase().equals("ooo") ||
+ getReferenceType().toLowerCase().equals("o3") )
{
if (xMSF == null)
{
diff --git a/qadevOOo/runner/graphical/PostscriptCreator.java b/qadevOOo/runner/graphical/PostscriptCreator.java
index 33511df1e..ba3228cfb 100644
--- a/qadevOOo/runner/graphical/PostscriptCreator.java
+++ b/qadevOOo/runner/graphical/PostscriptCreator.java
@@ -59,7 +59,8 @@ public class PostscriptCreator extends EnhancedComplexTestCase
public void checkOneFile(String _sDocumentName, String _sResult, ParameterHelper _aParams) throws OfficeException
{
- GlobalLogWriter.println("Document: " + _sDocumentName + " results: " + _sResult);
+ GlobalLogWriter.println(" Document: " + _sDocumentName);
+ GlobalLogWriter.println(" results: " + _sResult);
IOffice aOffice = new Office(_aParams, _sResult);
PerformanceContainer a = new PerformanceContainer();
diff --git a/qadevOOo/runner/helper/OfficeProvider.java b/qadevOOo/runner/helper/OfficeProvider.java
index 54588117f..f14bf7e88 100644
--- a/qadevOOo/runner/helper/OfficeProvider.java
+++ b/qadevOOo/runner/helper/OfficeProvider.java
@@ -59,7 +59,7 @@ import util.utils;
public class OfficeProvider implements AppProvider
{
- protected static boolean debug = false;
+ private static boolean debug = false;
/**
* copy the user layer to a safe place, usualy to $TMP/user_backup$USER
@@ -355,7 +355,7 @@ public class OfficeProvider implements AppProvider
if (rInitialObject != null)
{
- debug = true;
+ // debug = true;
dbg("resolved url");
xMSF = UnoRuntime.queryInterface(XMultiServiceFactory.class, rInitialObject);
@@ -434,7 +434,7 @@ public class OfficeProvider implements AppProvider
{
XMultiServiceFactory msf = null;
String exc = "";
- debug = true;
+ // debug = true;
dbg("trying to connect to " + cncstr);
diff --git a/qadevOOo/runner/helper/ProcessHandler.java b/qadevOOo/runner/helper/ProcessHandler.java
index 336f64173..63f1d770e 100644
--- a/qadevOOo/runner/helper/ProcessHandler.java
+++ b/qadevOOo/runner/helper/ProcessHandler.java
@@ -26,6 +26,7 @@
************************************************************************/
package helper;
+import java.io.BufferedReader;
import java.io.InputStream;
import java.io.File;
import java.io.PrintWriter;
@@ -33,10 +34,12 @@ import java.io.PrintStream;
import java.io.LineNumberReader;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
+import java.io.Writer;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import lib.TestParameters;
+import share.LogWriter;
import util.PropertyName;
import util.utils;
@@ -58,6 +61,7 @@ class Pump extends Thread
private String pref;
private StringBuffer buf = new StringBuffer(256);
private PrintWriter log;
+ private boolean bOutput;
/**
* Creates Pump for specified <code>InputStream</code>.
@@ -70,11 +74,12 @@ class Pump extends Thread
* @param outPrefix A prefix which is printed at the
* beginning of each output line.
*/
- public Pump(InputStream is, PrintWriter log, String outPrefix)
+ public Pump(InputStream is, PrintWriter log, String outPrefix, boolean _bOutput)
{
this.pref = (outPrefix == null) ? "" : outPrefix;
reader = new LineNumberReader(new InputStreamReader(is));
this.log = log;
+ this.bOutput = _bOutput;
start();
}
@@ -85,8 +90,11 @@ class Pump extends Thread
String line = reader.readLine();
while (line != null)
{
- log.println(pref + line);
- log.flush();
+ if (bOutput)
+ {
+ log.println(pref + line);
+ log.flush();
+ }
buf.append(line).append('\n');
line = reader.readLine();
}
@@ -133,6 +141,11 @@ public class ProcessHandler
private Process m_aProcess = null;
private TestParameters param = null;
private boolean debug = false;
+ private boolean bUseOutput = true;
+
+ private int m_nProcessTimeout = 0;
+ private String m_sProcessKiller;
+ private ProcessWatcher m_aWatcher;
/**
* Creates instance with specified external command.
@@ -348,6 +361,24 @@ public class ProcessHandler
}
/**
+ * If not equal 0, the time to maximal wait.
+ * @param _n
+ */
+ public void setProcessTimeout(int _n)
+ {
+ m_nProcessTimeout = _n;
+ }
+
+ /**
+ * This command will call after ProcessTimeout is arrived.
+ * @param _s
+ */
+ public void setProcessKiller(String _s)
+ {
+ m_sProcessKiller = _s;
+ }
+
+ /**
* This method do an asynchronous execution of the commands. To avoid a interruption on long running processes
* caused by <CODE>OfficeWatcher</CODE>, the OfficeWatcher get frequently a ping.
* @see helper.OfficeWatcher
@@ -395,7 +426,7 @@ public class ProcessHandler
if (sOutputText.length() == memText.length())
{
changedText = false;
- // dbg("runCommand Could not detect changes in output stream!!!");
+ // dbg("runCommand Could not detect changes in output stream!!!");
}
hangcheck = 10;
memText = this.getOutputText();
@@ -515,6 +546,21 @@ public class ProcessHandler
return m_nExactStartTimeInMillisec;
}
+ private void showEnvVars()
+ {
+ if (envVars != null)
+ {
+ for (int i = 0; i < envVars.length; i++)
+ {
+ log.println("env: " + envVars[i]);
+ }
+ }
+ else
+ {
+ log.println("env: null");
+ }
+ }
+
protected void execute()
{
if (isStarted())
@@ -527,27 +573,32 @@ public class ProcessHandler
{
if (cmdLine == null)
{
- log.print(utils.getDateTime() + "execute: Starting command from array: ");
+ log.println(utils.getDateTime() + "execute: Starting command from array: ");
for (int i = 0; i < cmdLineArray.length; i++)
{
- log.print(cmdLineArray[i]);
- log.print(" ");
+ log.println(cmdLineArray[i]);
+ // log.print(" ");
}
+ showEnvVars();
log.println("");
initialExactStartTime();
+ initializeProcessKiller();
m_aProcess = runtime.exec(cmdLineArray, envVars);
}
else
{
if (workDir != null)
{
- log.println(utils.getDateTime() + "execute: Starting command: " + cmdLine + " " +
- workDir.getAbsolutePath());
+ log.println(utils.getDateTime() + "execute: Starting command: ");
+ log.println(cmdLine + " path=" + workDir.getAbsolutePath());
+ showEnvVars();
m_aProcess = runtime.exec(cmdLine, envVars, workDir);
}
else
{
- log.println(utils.getDateTime() + "execute: Starting command: " + cmdLine);
+ log.println(utils.getDateTime() + "execute: Starting command: ");
+ log.println(cmdLine);
+ showEnvVars();
m_aProcess = runtime.exec(cmdLine, envVars);
}
}
@@ -566,8 +617,8 @@ public class ProcessHandler
return;
}
dbg("execute: pump io-streams");
- stdout = new Pump(m_aProcess.getInputStream(), log, "out > ");
- stderr = new Pump(m_aProcess.getErrorStream(), log, "err > ");
+ stdout = new Pump(m_aProcess.getInputStream(), log, "out > ", bUseOutput);
+ stderr = new Pump(m_aProcess.getErrorStream(), log, "err > ", bUseOutput);
stdIn = new PrintStream(m_aProcess.getOutputStream());
// int nExitValue = m_aProcess.exitValue();
@@ -821,4 +872,139 @@ public class ProcessHandler
log.println(utils.getDateTime() + "PH." + message);
}
}
+
+ public void noOutput()
+ {
+ bUseOutput = false;
+ }
+ // -------------------------------------------------------------------------
+ class ProcessWatcher extends Thread
+ {
+
+ private int m_nTimeoutInSec;
+ private String m_sProcessToStart;
+ private boolean m_bInterrupt;
+
+ public ProcessWatcher(int _nTimeOut, String _sProcess)
+ {
+ m_nTimeoutInSec = _nTimeOut;
+ m_sProcessToStart = _sProcess;
+ m_bInterrupt = false;
+ }
+
+ /**
+ * returns true, if the thread should hold on
+ * @return
+ */
+ public synchronized boolean isInHoldOn()
+ {
+ return m_bInterrupt;
+ }
+ /**
+ * Marks the thread to hold on, next time
+ * STUPID: The thread must poll this flag itself.
+ *
+ * Reason: interrupt() seems not to work as expected.
+ */
+ public synchronized void holdOn()
+ {
+ m_bInterrupt = true;
+ interrupt();
+ }
+
+ public void run()
+ {
+ while (m_nTimeoutInSec > 0)
+ {
+ m_nTimeoutInSec--;
+ try
+ {
+ sleep(1000);
+ }
+ catch(java.lang.InterruptedException e)
+ {
+ // interrupt flag is set back to 'not interrupted' :-(
+ }
+ if (isInHoldOn())
+ {
+ break;
+ }
+ }
+ if (m_nTimeoutInSec <= 0 && !isInHoldOn()) // not zero, so we are interrupted.
+ {
+ system(m_sProcessToStart);
+ }
+ }
+
+ /**
+ * Start an external Process
+ * @param _sProcess
+ */
+ private void system(String _sProcess)
+ {
+ if (_sProcess == null)
+ {
+ return;
+ }
+
+ try
+ {
+
+ // run a _sProcess command
+ // using the Runtime exec method:
+ Process p = Runtime.getRuntime().exec(_sProcess);
+
+ BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));
+
+ BufferedReader stdError = new BufferedReader(new InputStreamReader(p.getErrorStream()));
+
+ // read the output from the command
+ String s;
+ while ((s = stdInput.readLine()) != null)
+ {
+ System.out.println("out:" + s);
+ }
+
+ // read any errors from the attempted command
+ while ((s = stdError.readLine()) != null)
+ {
+ System.out.println("err:" + s);
+ }
+
+ }
+ catch (java.io.IOException e)
+ {
+ System.out.println("exception caught: ");
+ e.printStackTrace();
+ }
+
+ }
+ }
+
+ /**
+ * If the timeout only given by setProcessTimeout(int seconds) function is != 0,
+ * a extra thread is created and after time has run out, the ProcessKiller string
+ * given by function setProcessKiller(string) will execute.
+ * So it is possible to kill a running office after a given time of seconds.
+ */
+ private void initializeProcessKiller()
+ {
+ if (m_nProcessTimeout != 0)
+ {
+ m_aWatcher = new ProcessWatcher(m_nProcessTimeout, m_sProcessKiller);
+ m_aWatcher.start();
+ }
+ }
+
+ /**
+ * to stop the extra thread, before he will kill a running office. This will stop the thread.
+ */
+ public void stopWatcher()
+ {
+ if (m_aWatcher != null)
+ {
+ m_aWatcher.holdOn();
+ shortWait(5000);
+ }
+ }
}
diff --git a/qadevOOo/runner/org/openoffice/Runner.java b/qadevOOo/runner/org/openoffice/Runner.java
index cdcefc992..73707d2f6 100644
--- a/qadevOOo/runner/org/openoffice/Runner.java
+++ b/qadevOOo/runner/org/openoffice/Runner.java
@@ -184,7 +184,7 @@ public class Runner
public static boolean run(String... args)
{
- System.out.println("OOoRunner Main() version from 20100323 (yyyymmdd)");
+ System.out.println("OOoRunner Main() version from 20101118 (yyyymmdd)");
setStartTime(getTime());
diff --git a/qadevOOo/runner/stats/Summarizer.java b/qadevOOo/runner/stats/Summarizer.java
index 2d28ea1fe..16fb3d880 100644
--- a/qadevOOo/runner/stats/Summarizer.java
+++ b/qadevOOo/runner/stats/Summarizer.java
@@ -78,7 +78,7 @@ public class Summarizer
{
if (states.elementAt(j).equals("not part of the job"))
{
- state = "Not possible since not all Interfaces/Services have been checked";
+ state = "PASSED(some interfaces/services not tested).OK";
}
else
{