summaryrefslogtreecommitdiff
path: root/qadevOOo/runner
diff options
context:
space:
mode:
authorRelease Engineers <releng@openoffice.org>2009-07-03 10:14:57 +0000
committerRelease Engineers <releng@openoffice.org>2009-07-03 10:14:57 +0000
commitb37f665758a8eebc1cbeb0155d7d24787ca3401e (patch)
treeb864924e5b8d77a106fe477881de7ccdc10bc91a /qadevOOo/runner
parent6a64591a8774d2cb7057fff5af1af21c6e6c01b2 (diff)
CWS-TOOLING: integrate CWS perftest08
2009-07-02 10:03:16 +0200 lla r273621 : #159516# support systems with no JAVA_HOME 2009-07-02 10:00:25 +0200 lla r273620 : #159516# if path is null this not an error 2009-07-01 14:36:05 +0200 lla r273583 : #159516# add check for wrong cygwin path 2009-06-22 13:18:14 +0200 lla r273223 : #159516# add PipeConnectionString 2009-06-18 21:44:59 +0200 lla r273137 : #159516# cleanups 2009-06-18 21:44:17 +0200 lla r273136 : #159516# handle null 2009-06-18 21:42:56 +0200 lla r273135 : #159516# add getElementCount() function 2009-06-15 10:40:05 +0200 lla r272966 : CWS-TOOLING: rebase CWS perftest08 to trunk@272827 (milestone: DEV300:m50) 2009-06-02 09:06:22 +0200 lla r272480 : CWS-TOOLING: rebase CWS perftest08 to trunk@272291 (milestone: DEV300:m49) 2009-05-08 11:40:22 +0200 mib r271710 : #159717#: File name info for performance test (added void to hasLogFile() parameter list) 2009-05-05 14:14:25 +0200 mib r271514 : #159717#: File name info for performance test 2009-05-04 15:23:01 +0200 mib r271466 : #159717#: File name infor for performance test 2009-05-04 15:22:27 +0200 mib r271465 : #159717#: File name infor for performance test 2009-05-04 15:21:56 +0200 mib r271464 : #159717#: File name infor for performance test 2009-05-04 15:21:18 +0200 mib r271462 : #159717#: File name infor for performance test 2009-04-29 16:23:40 +0200 lla r271383 : #159516# cleanups 2009-04-29 16:23:20 +0200 lla r271382 : #159516# cleanups 2009-04-08 12:23:01 +0200 lla r270631 : #159516# typo 2009-04-07 10:30:35 +0200 lla r270580 : #159516# add prototype 2009-04-07 10:21:15 +0200 lla r270579 : #159516# cleanup 2009-04-03 09:05:26 +0200 lla r270448 : #159516# small cleanups 2009-03-30 13:22:26 +0200 lla r270221 : #159517# merge perftest07
Diffstat (limited to 'qadevOOo/runner')
-rw-r--r--qadevOOo/runner/base/java_complex.java69
-rw-r--r--qadevOOo/runner/complexlib/ComplexTestCase.java131
-rw-r--r--qadevOOo/runner/graphical/IniFile.java19
-rw-r--r--qadevOOo/runner/graphical/JPEGComparator.java3
-rw-r--r--qadevOOo/runner/helper/CfgParser.java116
-rw-r--r--qadevOOo/runner/helper/ClParser.java79
-rw-r--r--qadevOOo/runner/helper/ComplexDescGetter.java87
-rw-r--r--qadevOOo/runner/helper/OfficeProvider.java395
-rw-r--r--qadevOOo/runner/helper/ProcessHandler.java340
-rw-r--r--qadevOOo/runner/lib/TestParameters.java7
-rw-r--r--qadevOOo/runner/org/openoffice/Runner.java158
-rw-r--r--qadevOOo/runner/util/DesktopTools.java8
-rw-r--r--qadevOOo/runner/util/PropertyName.java3
13 files changed, 972 insertions, 443 deletions
diff --git a/qadevOOo/runner/base/java_complex.java b/qadevOOo/runner/base/java_complex.java
index 0690fb8a0138..e3a41ca19d5c 100644
--- a/qadevOOo/runner/base/java_complex.java
+++ b/qadevOOo/runner/base/java_complex.java
@@ -27,7 +27,6 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
-
package base;
import complexlib.ComplexTestCase;
@@ -47,7 +46,8 @@ import util.PropertyName;
* Test base for executing a java complex test.
* @see base.TestBase
*/
-public class java_complex implements TestBase{
+public class java_complex implements TestBase
+{
/**
* This function executes the complex tests given as parameter "-o" or "TestJob". It querys for the correspond class
@@ -55,40 +55,42 @@ public class java_complex implements TestBase{
* @param param
* @return true of all tests run successfuly, esle false
*/
- public boolean executeTest(TestParameters param) {
+ public boolean executeTest(TestParameters param)
+ {
// is there an ini file for the complex tests defined?
- String complexIniFileName = ((String)param.get("ComplexIni"));
- if (complexIniFileName != null) {
+ String complexIniFileName = ((String) param.get("ComplexIni"));
+ if (complexIniFileName != null)
+ {
CfgParser ini = new CfgParser(complexIniFileName);
ini.getIniParameters(param);
}
// get the test job
- String testJob = ((String)param.get("TestJob"));
+ String testJob = ((String) param.get("TestJob"));
DescGetter descGetter = new ComplexDescGetter();
// get the test jobs
- DescEntry[] entries = descGetter.getDescriptionFor(testJob,null,true);
+ DescEntry[] entries = descGetter.getDescriptionFor(testJob, null, true);
return executeTest(param, entries);
}
-
/**
* This function run the given DescEntry[] as ComplexTest
* @param param
* @param entries
* @return true of all tests run successfuly, esle false
*/
- public boolean executeTest(TestParameters param, DescEntry[] entries) {
+ public boolean executeTest(TestParameters param, DescEntry[] entries)
+ {
// is there an ini file for the complex tests defined?
- String complexIniFileName = ((String)param.get("ComplexIni"));
- if (complexIniFileName != null)
+ String complexIniFileName = ((String) param.get("ComplexIni"));
+ if (complexIniFileName != null)
{
CfgParser ini = new CfgParser(complexIniFileName);
ini.getIniParameters(param);
- }
+ }
DynamicClassLoader dcl = new DynamicClassLoader();
ComplexTestCase testClass = null;
@@ -104,40 +106,49 @@ public class java_complex implements TestBase{
// param.put("TimeOut", new Integer(0));
- for (int i=0; i<entries.length; i++) {
+ for (int i = 0; i < entries.length; i++)
+ {
- if (entries[i] == null) continue;
+ if (entries[i] == null)
+ {
+ continue;
+ }
String iniName = entries[i].longName;
iniName = iniName.replace('.', '/');
- CfgParser ini = new CfgParser(iniName+".props");
+ CfgParser ini = new CfgParser(iniName + ".props");
ini.getIniParameters(param);
- LogWriter log = (LogWriter)dcl.getInstance(
- (String)param.get("LogWriter"));
+ LogWriter log = (LogWriter) dcl.getInstance((String) param.get("LogWriter"));
AppProvider office = null;
- if (!param.getBool("NoOffice")) {
- try {
- office = (AppProvider)dcl.getInstance("helper.OfficeProvider");
+ if (!param.getBool("NoOffice"))
+ {
+ try
+ {
+ office = (AppProvider) dcl.getInstance("helper.OfficeProvider");
Object msf = office.getManager(param);
- if (msf == null) {
+ if (msf == null)
+ {
returnVal = false;
continue;
}
- param.put("ServiceFactory",msf);
+ param.put("ServiceFactory", msf);
}
- catch(IllegalArgumentException e) {
+ catch (IllegalArgumentException e)
+ {
office = null;
}
}
- log.initialize(entries[i],param.getBool(PropertyName.LOGGING_IS_ACTIVE));
+ log.initialize(entries[i], param.getBool(PropertyName.LOGGING_IS_ACTIVE));
entries[i].Logger = log;
// create an instance
- try {
- testClass = (ComplexTestCase)dcl.getInstance(entries[i].longName);
+ try
+ {
+ testClass = (ComplexTestCase) dcl.getInstance(entries[i].longName);
}
- catch(java.lang.Exception e) {
+ catch (java.lang.Exception e)
+ {
e.printStackTrace();
return false;
}
@@ -146,7 +157,8 @@ public class java_complex implements TestBase{
Summarizer sum = new Summarizer();
sum.summarizeUp(entries[i]);
- if (office != null) {
+ if (office != null)
+ {
office.closeExistingOffice(param, false);
}
@@ -158,5 +170,4 @@ public class java_complex implements TestBase{
}
return returnVal;
}
-
}
diff --git a/qadevOOo/runner/complexlib/ComplexTestCase.java b/qadevOOo/runner/complexlib/ComplexTestCase.java
index 4fb5d757fb0e..f31cf1810106 100644
--- a/qadevOOo/runner/complexlib/ComplexTestCase.java
+++ b/qadevOOo/runner/complexlib/ComplexTestCase.java
@@ -27,7 +27,6 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
-
package complexlib;
import java.lang.reflect.Method;
@@ -38,11 +37,11 @@ import share.LogWriter;
import share.ComplexTest;
import java.io.PrintWriter;
-
/**
* Base class for all complex tests.
*/
-public abstract class ComplexTestCase extends Assurance implements ComplexTest {
+public abstract class ComplexTestCase extends Assurance implements ComplexTest
+{
/** The test parameters **/
protected static TestParameters param = null;
@@ -70,31 +69,42 @@ public abstract class ComplexTestCase extends Assurance implements ComplexTest {
* @param entry The name of the test method that should be called.
* @param environment The environment for the test.
*/
- public void executeMethods(DescEntry entry, TestParameters environment) {
+ public void executeMethods(DescEntry entry, TestParameters environment)
+ {
// get the environment
param = environment;
log = entry.Logger;
mThreadTimeOut = param.getInt("ThreadTimeOut");
- if (mThreadTimeOut == 0) {
+ if (mThreadTimeOut == 0)
+ {
mThreadTimeOut = 300000;
}
// start with the before() method
boolean beforeWorked = true;
- try {
- Method before = this.getClass().getMethod("before", new Class[]{});
- before.invoke(this, new Object[]{});
- } catch (java.lang.NoSuchMethodException e) {
+ try
+ {
+ Method before = this.getClass().getMethod("before", new Class[] {} );
+ before.invoke(this, new Object[] {} );
+ }
+ catch (java.lang.NoSuchMethodException e)
+ {
// simply ignore
- } catch (java.lang.IllegalAccessException e) {
+ }
+ catch (java.lang.IllegalAccessException e)
+ {
log.println("Cannot access the 'before()' method, although it" + " is there. Is this ok?");
- } catch (java.lang.reflect.InvocationTargetException e) {
+ }
+ catch (java.lang.reflect.InvocationTargetException e)
+ {
beforeWorked = false;
Throwable t = e.getTargetException();
- if (!(t instanceof RuntimeException) || state) {
+ if (!(t instanceof RuntimeException) || state)
+ {
log.println(t.toString());
- if (message == null) {
+ if (message == null)
+ {
message = "Exception in before() method.\n\r" + t.getMessage();
}
state = false;
@@ -104,12 +114,16 @@ public abstract class ComplexTestCase extends Assurance implements ComplexTest {
//executeMethodTests
- for (int i = 0; i < entry.SubEntries.length; i++) {
+ for (int i = 0; i < entry.SubEntries.length; i++)
+ {
subEntry = entry.SubEntries[i];
- if (beforeWorked) {
+ if (beforeWorked)
+ {
state = true;
message = "";
- } else {
+ }
+ else
+ {
// set all test methods on failed, if 'before()' did not work.
subEntry.State = message;
subEntry.hasErrorMsg = true;
@@ -117,18 +131,25 @@ public abstract class ComplexTestCase extends Assurance implements ComplexTest {
continue;
}
Method testMethod = null;
- try {
+ try
+ {
String entryName = subEntry.entryName;
Object[] parameter = null;
- if (entryName.indexOf("(") != -1) {
- String sParameter = (entryName.substring(entryName.indexOf("(") +1 , entryName.indexOf(")")));
+ if (entryName.indexOf("(") != -1)
+ {
+ String sParameter = (entryName.substring(entryName.indexOf("(") + 1, entryName.indexOf(")")));
mTestMethodName = entryName;
- parameter = new String[] {sParameter};
+ parameter = new String[]
+ {
+ sParameter
+ };
entryName = entryName.substring(0, entryName.indexOf("("));
- testMethod = this.getClass().getMethod(entryName, new Class[]{String.class });
- } else {
- testMethod = this.getClass().getMethod(entryName, new Class[]{});
+ testMethod = this.getClass().getMethod(entryName, new Class[] { String.class });
+ }
+ else
+ {
+ testMethod = this.getClass().getMethod(entryName, new Class[] {} );
mTestMethodName = entryName;
}
@@ -136,7 +157,8 @@ public abstract class ComplexTestCase extends Assurance implements ComplexTest {
log.println("Starting " + mTestMethodName);
th.start();
- try {
+ try
+ {
// some tests are very dynamic in its exceution time so that
// a threadTimeOut fials. In this cases the logging mechanisim
// is a usefull way to detect that a office respective a test
@@ -150,38 +172,48 @@ public abstract class ComplexTestCase extends Assurance implements ComplexTest {
int sleepingStep = 1000;
int factor = 0;
- while (th.isAlive() && (lastPing != newPing || factor * sleepingStep < mThreadTimeOut)) {
+ while (th.isAlive() && (lastPing != newPing || factor * sleepingStep < mThreadTimeOut))
+ {
Thread.sleep(sleepingStep);
factor++;
// if a test starts the office itself it the watcher is a
// new one.
share.Watcher ow = (share.Watcher) param.get("Watcher");
- if (ow != null) {
+ if (ow != null)
+ {
lastPing = newPing;
newPing = ow.getPing();
//System.out.println("lastPing: '" + lastPing + "' newPing '" + newPing + "'");
factor = 0;
}
}
- } catch (InterruptedException e) {
}
- if (th.isAlive()) {
+ catch (InterruptedException e)
+ {
+ }
+ if (th.isAlive())
+ {
log.println("Destroy " + mTestMethodName);
th.destroy();
subEntry.State = "Test did sleep for " + (mThreadTimeOut / 1000) + " seconds and has been killed!";
subEntry.hasErrorMsg = true;
subEntry.ErrorMsg = subEntry.State;
continue;
- } else {
+ }
+ else
+ {
log.println("Finished " + mTestMethodName);
- if (th.hasErrorMessage()) {
+ if (th.hasErrorMessage())
+ {
subEntry.State = th.getErrorMessage();
subEntry.hasErrorMsg = true;
subEntry.ErrorMsg = subEntry.State;
continue;
}
}
- } catch (java.lang.Exception e) {
+ }
+ catch (java.lang.Exception e)
+ {
log.println(e.getClass().getName());
String msg = e.getMessage();
log.println("Message: " + msg);
@@ -196,22 +228,34 @@ public abstract class ComplexTestCase extends Assurance implements ComplexTest {
subEntry.ErrorMsg = message;
}
- if (beforeWorked) {
+ if (beforeWorked)
+ {
// the after() method
- try {
- Method after = this.getClass().getMethod("after", new Class[]{});
- after.invoke(this, new Object[]{});
- } catch (java.lang.NoSuchMethodException e) {
+ try
+ {
+ Method after = this.getClass().getMethod("after", new Class[] {});
+ after.invoke(this, new Object[] {} );
+ }
+ catch (java.lang.NoSuchMethodException e)
+ {
// simply ignore
- } catch (java.lang.IllegalAccessException e) {
+ }
+ catch (java.lang.IllegalAccessException e)
+ {
// simply ignore
- } catch (java.lang.reflect.InvocationTargetException e) {
+ }
+ catch (java.lang.reflect.InvocationTargetException e)
+ {
Throwable t = e.getTargetException();
- if (!(t instanceof StatusException)) {
+ if (!(t instanceof StatusException))
+ {
log.println(t.toString());
- if (message == null) {
+ if (message == null)
+ {
message = "Exception in after() method.\n\r" + t.getMessage();
- } else {
+ }
+ else
+ {
message += "Exception in \'after()\' method.\n\r" + t.getMessage();
}
log.println("Message: " + message);
@@ -232,9 +276,8 @@ public abstract class ComplexTestCase extends Assurance implements ComplexTest {
* Override to give an own name.
* @return As default, the name of this class.
*/
- public String getTestObjectName() {
+ public String getTestObjectName()
+ {
return this.getClass().getName();
}
-
-
} \ No newline at end of file
diff --git a/qadevOOo/runner/graphical/IniFile.java b/qadevOOo/runner/graphical/IniFile.java
index c1aa6456d166..4dffb07b8ed8 100644
--- a/qadevOOo/runner/graphical/IniFile.java
+++ b/qadevOOo/runner/graphical/IniFile.java
@@ -39,7 +39,7 @@ import java.util.Enumeration;
Helper class to give a simple API to read/write windows like ini files
*/
/* public */ // is only need, if we need this class outside package convwatch
-class IniFile implements Enumeration
+public class IniFile implements Enumeration
{
/**
* internal representation of the ini file content.
@@ -659,4 +659,21 @@ public void removeSection(String _sSectionToRemove)
}
return null;
}
+
+ /**
+ * Helper to count the occurence of Sections
+ * @return returns the count of '^['.*']$' Elements
+ */
+ public int getElementCount()
+ {
+ int nCount = 0;
+ int nPosition = 0;
+ while ((nPosition = findNextSection(nPosition)) != -1)
+ {
+ nCount ++;
+ nPosition ++;
+ }
+ return nCount;
+ }
}
+
diff --git a/qadevOOo/runner/graphical/JPEGComparator.java b/qadevOOo/runner/graphical/JPEGComparator.java
index 6bde326dacb1..ca7d72b0963c 100644
--- a/qadevOOo/runner/graphical/JPEGComparator.java
+++ b/qadevOOo/runner/graphical/JPEGComparator.java
@@ -265,6 +265,9 @@ public class JPEGComparator extends EnhancedComplexTestCase
_aParams.getTestParameters().put("current_state", sStatusRunThrough);
_aParams.getTestParameters().put("current_info", sStatusMessage);
_aParams.getTestParameters().put("current_ok_status", ok_status);
+
+ // if we have a ugly page, we must return this as a FAILED STATUS in Log file!
+ // assure( "There exist pages marked as ugly.", ugly == 0)
}
private void checkOnePicture(String _sDocumentName, String _sResult, ParameterHelper _aParams)
diff --git a/qadevOOo/runner/helper/CfgParser.java b/qadevOOo/runner/helper/CfgParser.java
index 95ea722481a8..19d2d561f666 100644
--- a/qadevOOo/runner/helper/CfgParser.java
+++ b/qadevOOo/runner/helper/CfgParser.java
@@ -27,7 +27,6 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
-
package helper;
import lib.TestParameters;
@@ -41,48 +40,65 @@ import util.PropertyName;
* <br>
* inside TestParameters
*/
-public class CfgParser {
+public class CfgParser
+{
+
protected boolean debug = false;
- protected String iniFile="";
+ protected String iniFile = "";
- public CfgParser(String ini) {
+ public CfgParser(String ini)
+ {
if (ini != null)
+ {
this.iniFile = ini;
+ }
}
- public void getIniParameters(TestParameters param) {
+ public void getIniParameters(TestParameters param)
+ {
debug = param.DebugIsActive;
Properties cfg = null;
- if (iniFile.equals("")) {
+ if (iniFile.equals(""))
+ {
//no iniFile given, search one in the users home directory
cfg = getProperties(getDefaultFileName(true));
//try to search the user dir if no iniFile could be found yet
- if (cfg == null) {
+ if (cfg == null)
+ {
cfg = getProperties(getDefaultFileName(false));
}
- } else {
+ }
+ else
+ {
cfg = getProperties(iniFile);
}
- if (cfg != null) {
+ if (cfg != null)
+ {
Enumeration cfgEnum = cfg.keys();
- while (cfgEnum.hasMoreElements()) {
+ while (cfgEnum.hasMoreElements())
+ {
String pName = (String) cfgEnum.nextElement();
Object pValue = cfg.getProperty(pName);
- if (pValue instanceof String) pValue = ((String)pValue).trim();
+ if (pValue instanceof String)
+ {
+ pValue = ((String) pValue).trim();
+ }
- param.put(pName.trim(),pValue);
+ param.put(pName.trim(), pValue);
- if (pName.equals(PropertyName.TEST_DOCUMENT_PATH)) {
+ if (pName.equals(PropertyName.TEST_DOCUMENT_PATH))
+ {
- param.put("DOCPTH",(String)pValue);
- System.setProperty("DOCPTH",(String)pValue);
+ param.put("DOCPTH", (String) pValue);
+ System.setProperty("DOCPTH", (String) pValue);
}
- if (pName.equals(PropertyName.SRC_ROOT)) {
+ else if (pName.equals(PropertyName.SRC_ROOT))
+ {
- System.setProperty(pName,(String)pValue);
+ System.setProperty(pName, (String) pValue);
}
}
@@ -93,45 +109,57 @@ public class CfgParser {
//check for platform dependend parameters
//this would have a $OperatingSystem as prefix
String os = (String) param.get(PropertyName.OPERATING_SYSTEM);
- if (os != null && os.length()>1) {
+ if (os != null && os.length() > 1)
+ {
//found something that could be a prefex
//check all parameters for this
Enumeration keys = param.keys();
- while (keys.hasMoreElements()) {
+ while (keys.hasMoreElements())
+ {
String key = (String) keys.nextElement();
- if (key.startsWith(os)) {
+ if (key.startsWith(os))
+ {
Object oldValue = param.get(key);
- String newKey = key.substring(os.length()+1);
+ String newKey = key.substring(os.length() + 1);
param.remove(key);
- param.put(newKey,oldValue);
+ param.put(newKey, oldValue);
}
}
}
}
- protected Properties getProperties(String name) {
+ protected Properties getProperties(String name)
+ {
// get the resource file
Properties prop = new Properties();
- if ( debug ) {
- System.out.println("Looking for "+name);
+ if (debug)
+ {
+ System.out.println("Looking for " + name);
}
- try {
+ try
+ {
FileInputStream propFile = new FileInputStream(name);
prop.load(propFile);
- System.out.println("Parsing properties from "+name);
+ System.out.println("Parsing properties from " + name);
propFile.close();
- } catch (Exception e) {
- try {
- java.net.URL url = this.getClass().getResource("/"+name);
- if (url != null) {
- System.out.println("Parsing properties from "+name);
+ }
+ catch (Exception e)
+ {
+ try
+ {
+ java.net.URL url = this.getClass().getResource("/" + name);
+ if (url != null)
+ {
+ System.out.println("Parsing properties from " + name);
java.net.URLConnection connection = url.openConnection();
java.io.InputStream in = connection.getInputStream();
prop.load(in);
}
- } catch (Exception ex) {
+ }
+ catch (Exception ex)
+ {
//Exception while reading prop-file, returning null
return null;
}
@@ -140,22 +168,28 @@ public class CfgParser {
return prop;
}
- protected String getDefaultFileName(boolean home) {
+ protected String getDefaultFileName(boolean home)
+ {
String fileSeparator = System.getProperty("file.separator");
String path = "";
- if (home) {
+ if (home)
+ {
//look inside the home directory
path = System.getProperty("user.home");
- } else {
+ }
+ else
+ {
path = System.getProperty("user.dir");
}
- if (fileSeparator.equals("/")) {
+ if (fileSeparator.equals("/"))
+ {
//suppose I'm on Unix-platform
- return path+fileSeparator+".runner.props";
- } else {
+ return path + fileSeparator + ".runner.props";
+ }
+ else
+ {
//suppose I'm on Windows
- return path+fileSeparator+"runner.props";
+ return path + fileSeparator + "runner.props";
}
}
-
}
diff --git a/qadevOOo/runner/helper/ClParser.java b/qadevOOo/runner/helper/ClParser.java
index eddd351fdb0a..c88b14a6028b 100644
--- a/qadevOOo/runner/helper/ClParser.java
+++ b/qadevOOo/runner/helper/ClParser.java
@@ -39,54 +39,74 @@ import util.utils;
* This class parses commandline Argument and stores <br>
* them into TestParameter
*/
-public class ClParser {
+public class ClParser
+{
/*
* Parses the commandline argument and puts them<br>
* into the TestParameters
*/
- public void getCommandLineParameter(TestParameters param, String[] args) {
+ public void getCommandLineParameter(TestParameters param, String[] args)
+ {
Properties mapping = getMapping();
- for (int i = 0; i < args.length;) {
+ for (int i = 0; i < args.length;)
+ {
String pName = getParameterFor(mapping, args[i]).trim();
String pValue = "";
- if (pName.equals("TestJob")) {
- if (args.length > (i + 1)) {
+ if (pName.equals("TestJob"))
+ {
+ if (args.length > (i + 1))
+ {
pValue = args[i].trim() + " " + args[i + 1].trim();
i += 2;
- } else {
+ }
+ else
+ {
pValue = args[i].trim() + " unknown";
i += 2;
}
- } else {
- if ((i + 1) < args.length) {
+ }
+ else
+ {
+ if ((i + 1) < args.length)
+ {
pValue = args[i + 1].trim();
- if (pValue.startsWith("-")) {
+ if (pValue.startsWith("-"))
+ {
i++;
pValue = "yes";
- } else if (pValue.startsWith("'")) {
+ }
+ else if (pValue.startsWith("'"))
+ {
i++;
- while (!pValue.endsWith("'")) {
+ while (!pValue.endsWith("'"))
+ {
i++;
pValue = pValue + " " + args[i].trim();
}
pValue = utils.replaceAll13(pValue, "'", "");
i++;
- } else {
+ }
+ else
+ {
i += 2;
}
- if (pName.equals("TestDocumentPath")) {
+ if (pName.equals("TestDocumentPath"))
+ {
System.setProperty("DOCPTH", pValue);
}
- if (pName.equals(PropertyName.SRC_ROOT)) {
- System.setProperty(pName,pValue);
+ else if (pName.equals(PropertyName.SRC_ROOT))
+ {
+ System.setProperty(pName, pValue);
}
- } else {
+ }
+ else
+ {
pValue = "yes";
i++;
}
@@ -100,11 +120,14 @@ public class ClParser {
* This method returns the path to a Configuration file <br>
* if defined as command line parameter, an empty String elsewhere
*/
- public String getIniPath(String[] args) {
+ public String getIniPath(String[] args)
+ {
String iniFile = "";
- for (int i = 0; i < args.length; i++) {
- if (args[i].equals("-ini")) {
+ for (int i = 0; i < args.length; i++)
+ {
+ if (args[i].equals("-ini"))
+ {
iniFile = args[i + 1];
break;
}
@@ -117,11 +140,14 @@ public class ClParser {
* This method returns the path to a Configuration file <br>
* if defined as command line parameter, an empty String elsewhere
*/
- public String getRunnerIniPath(String[] args) {
+ public String getRunnerIniPath(String[] args)
+ {
String iniFile = "";
- for (int i = 0; i < args.length; i++) {
- if (args[i].equals("-runnerini")) {
+ for (int i = 0; i < args.length; i++)
+ {
+ if (args[i].equals("-runnerini"))
+ {
iniFile = args[i + 1];
break;
}
@@ -133,7 +159,8 @@ public class ClParser {
/*
* This method maps commandline Parameters to TestParameters
*/
- protected Properties getMapping() {
+ protected Properties getMapping()
+ {
Properties map = new Properties();
map.setProperty("-cs", "ConnectionString");
map.setProperty("-tb", "TestBase");
@@ -153,10 +180,12 @@ public class ClParser {
return map;
}
- protected String getParameterFor(Properties map, String name) {
+ protected String getParameterFor(Properties map, String name)
+ {
String ret = map.getProperty(name);
- if (ret == null) {
+ if (ret == null)
+ {
ret = name.substring(1);
}
diff --git a/qadevOOo/runner/helper/ComplexDescGetter.java b/qadevOOo/runner/helper/ComplexDescGetter.java
index 90f6bbbf133b..5ed9efcbb702 100644
--- a/qadevOOo/runner/helper/ComplexDescGetter.java
+++ b/qadevOOo/runner/helper/ComplexDescGetter.java
@@ -40,45 +40,56 @@ import share.LogWriter;
/**
*
*/
-public class ComplexDescGetter extends DescGetter {
+public class ComplexDescGetter extends DescGetter
+{
ComplexTest testClass;
/** Creates new ComplexDescGetter */
- public ComplexDescGetter() {
+ public ComplexDescGetter()
+ {
testClass = null;
}
public DescEntry[] getDescriptionFor(String entry, String DescPath,
- boolean debug) {
+ boolean debug)
+ {
// read scenario file
- if (entry.startsWith("-sce")) {
- DescEntry[] entries = getScenario(entry.substring(5),null,debug);
+ if (entry.startsWith("-sce"))
+ {
+ DescEntry[] entries = getScenario(entry.substring(5), null, debug);
return entries;
}
// one single job
- else if (entry.startsWith("-o")) {
+ else if (entry.startsWith("-o"))
+ {
DescEntry dEntry = getDescriptionForSingleJob(entry.substring(3), null, debug);
if (dEntry != null)
- return new DescEntry[] {dEntry};
+ {
+ return new DescEntry[]
+ {
+ dEntry
+ };
+ }
}
- System.out.println("Could not get a testjob with parameter '"
- + entry +"'");
+ System.out.println("Could not get a testjob with parameter '" + entry + "'");
// no job available
return null;
}
-
- protected DescEntry getDescriptionForSingleJob(String className, String descPath, boolean debug) {
+ protected DescEntry getDescriptionForSingleJob(String className, String descPath, boolean debug)
+ {
DynamicClassLoader dcl = new DynamicClassLoader();
String methodNames[] = null;
- if (debug) {
+ if (debug)
+ {
System.out.println("Searching Class: " + className);
}
int index = className.indexOf("::");
- if (index != -1) {
+ if (index != -1)
+ {
// case1: method()
// case2: method(param1,param2)
// case3: method1(param1,param2),method2(param1,param2)
@@ -88,43 +99,53 @@ public class ComplexDescGetter extends DescGetter {
String[] split = method.split("(?<=\\)),(?=\\w+)");
- for (int i = 0; i < split.length; i++) {
+ for (int i = 0; i < split.length; i++)
+ {
String meth = split[i];
- if (meth.endsWith("()")) meth = meth.substring(0, meth.length() - 2);
+ if (meth.endsWith("()"))
+ {
+ meth = meth.substring(0, meth.length() - 2);
+ }
methods.add(meth);
}
methodNames = new String[methods.size()];
- methodNames = (String[])methods.toArray(methodNames);
+ methodNames = (String[]) methods.toArray(methodNames);
}
// create an instance
- try {
- testClass = (ComplexTestCase)dcl.getInstance(className);
+ try
+ {
+ testClass = (ComplexTestCase) dcl.getInstance(className);
}
- catch(java.lang.IllegalArgumentException e) {
- System.out.println("Error while getting description for test '" +className + "' as a Complex test.");
+ catch (java.lang.IllegalArgumentException e)
+ {
+ System.out.println("Error while getting description for test '" + className + "' as a Complex test.");
return null;
}
- catch(java.lang.ClassCastException e) {
- System.out.println("The given class '" +className + "' is not a Complex test.");
+ catch (java.lang.ClassCastException e)
+ {
+ System.out.println("The given class '" + className + "' is not a Complex test.");
return null;
}
- if (debug) {
- System.out.println("Got test: "+((Object)testClass).toString());
+ if (debug)
+ {
+ System.out.println("Got test: " + ((Object) testClass).toString());
}
String testObjectName = className;
String[] testMethodNames = null;
- if (testMethodNames == null){
+ if (testMethodNames == null)
+ {
testMethodNames = testClass.getTestMethodNames();
}
- if (methodNames != null) {
+ if (methodNames != null)
+ {
testMethodNames = methodNames;
}
@@ -141,7 +162,8 @@ public class ComplexDescGetter extends DescGetter {
* @param log
* @return filled description entry
*/
- public DescEntry createTestDesc(String testObjectName, String className, String[] testMethodNames, LogWriter log){
+ public DescEntry createTestDesc(String testObjectName, String className, String[] testMethodNames, LogWriter log)
+ {
DescEntry dEntry = new DescEntry();
@@ -153,10 +175,11 @@ public class ComplexDescGetter extends DescGetter {
dEntry.Logger = log;
dEntry.SubEntryCount = testMethodNames.length;
dEntry.SubEntries = new DescEntry[dEntry.SubEntryCount];
- for (int i=0; i<dEntry.SubEntryCount; i++) {
+ for (int i = 0; i < dEntry.SubEntryCount; i++)
+ {
DescEntry aEntry = new DescEntry();
aEntry.entryName = testMethodNames[i];
- aEntry.longName = testObjectName +"::" + aEntry.entryName;
+ aEntry.longName = testObjectName + "::" + aEntry.entryName;
aEntry.isOptional = false;
aEntry.EntryType = "method";
aEntry.isToTest = true;
@@ -167,8 +190,8 @@ public class ComplexDescGetter extends DescGetter {
return dEntry;
}
- protected String[] createScenario(String descPath, String job, boolean debug) {
- return new String[]{};
+ protected String[] createScenario(String descPath, String job, boolean debug)
+ {
+ return new String[] {};
}
-
}
diff --git a/qadevOOo/runner/helper/OfficeProvider.java b/qadevOOo/runner/helper/OfficeProvider.java
index 36350899844d..c47413070e34 100644
--- a/qadevOOo/runner/helper/OfficeProvider.java
+++ b/qadevOOo/runner/helper/OfficeProvider.java
@@ -59,7 +59,8 @@ import util.utils;
* This class will connect the office and start it if possible
*
*/
-public class OfficeProvider implements AppProvider {
+public class OfficeProvider implements AppProvider
+{
protected static boolean debug = false;
@@ -68,8 +69,10 @@ public class OfficeProvider implements AppProvider {
* @param param
* @param msf
*/
- public void backupUserLayer(TestParameters param, XMultiServiceFactory msf) {
- try {
+ public void backupUserLayer(TestParameters param, XMultiServiceFactory msf)
+ {
+ try
+ {
final XStringSubstitution sts = createStringSubstitution(msf);
debug = param.getBool(PropertyName.DEBUG_IS_ACTIVE);
@@ -78,8 +81,8 @@ public class OfficeProvider implements AppProvider {
param.put("userLayer", userLayer);
final String copyLayer = util.utils.getUsersTempDir() + System.getProperty("file.separator") +
- "user_backup" +
- System.getProperty("user.name");
+ "user_backup" +
+ System.getProperty("user.name");
param.put("copyLayer", copyLayer);
@@ -88,13 +91,20 @@ public class OfficeProvider implements AppProvider {
OfficeWatcherPing owp = new OfficeWatcherPing((OfficeWatcher) param.get(PropertyName.OFFICE_WATCHER));
owp.start();
- FileTools.copyDirectory(new File(userLayer), new File(copyLayer), new String[]{"temp"});
+ FileTools.copyDirectory(new File(userLayer), new File(copyLayer), new String[]
+ {
+ "temp"
+ });
owp.finish();
- } catch (com.sun.star.container.NoSuchElementException e) {
+ }
+ catch (com.sun.star.container.NoSuchElementException e)
+ {
System.out.println("User Variable '$(user)' not defined.");
- } catch (java.io.IOException e) {
+ }
+ catch (java.io.IOException e)
+ {
System.out.println("Couldn't backup user layer");
e.printStackTrace();
}
@@ -107,30 +117,40 @@ public class OfficeProvider implements AppProvider {
* @param param
* @return return true if desktop is terminates, else false
*/
- public boolean disposeManager(lib.TestParameters param) {
+ public boolean disposeManager(lib.TestParameters param)
+ {
XMultiServiceFactory msf = (XMultiServiceFactory) param.getMSF();
- if (msf == null) {
+ if (msf == null)
+ {
return true;
- } else {
+ }
+ else
+ {
XDesktop desk = null;
- try {
+ try
+ {
desk = (XDesktop) UnoRuntime.queryInterface(XDesktop.class,
- msf.createInstance(
- "com.sun.star.frame.Desktop"));
- } catch (com.sun.star.uno.Exception ue) {
+ msf.createInstance(
+ "com.sun.star.frame.Desktop"));
+ }
+ catch (com.sun.star.uno.Exception ue)
+ {
return false;
}
msf = null;
- if (desk != null) {
+ if (desk != null)
+ {
desk.terminate();
return true;
- } else {
+ }
+ else
+ {
return false;
}
}
@@ -138,23 +158,29 @@ public class OfficeProvider implements AppProvider {
/**
* Method to get the ServiceManager of an Office
+ * @param param
+ * @return
*/
- public Object getManager(lib.TestParameters param) {
+ public Object getManager(lib.TestParameters param)
+ {
String errorMessage = null;
boolean bAppExecutionHasWarning = false;
debug = param.getBool(PropertyName.DEBUG_IS_ACTIVE);
String additionalArgs = (String) param.get(
- "AdditionalConnectionArguments");
+ "AdditionalConnectionArguments");
- if (additionalArgs == null) {
+ if (additionalArgs == null)
+ {
additionalArgs = ";";
- } else {
+ }
+ else
+ {
additionalArgs = "," + additionalArgs + ";";
}
final String cncstr = "uno:" + param.get("ConnectionString") + ";urp" +
- additionalArgs + "StarOffice.ServiceManager";
+ additionalArgs + "StarOffice.ServiceManager";
System.out.println("Connecting the Office with " + cncstr);
@@ -165,25 +191,29 @@ public class OfficeProvider implements AppProvider {
// Example: The UNO-API-Tests in the projects will be executed by calling
// 'damke'. This connects to an existing office. If the office crashes
// it is usefull to restart the office and continuing the tests.
- if ((param.getBool(util.PropertyName.AUTO_RESTART)) && (msf != null)) {
+ if ((param.getBool(util.PropertyName.AUTO_RESTART)) && (msf != null))
+ {
makeAppExecCommand(msf, param);
}
- if (msf == null) {
+ if (msf == null)
+ {
String exc = "";
Exception exConnectFailed = null;
boolean isExecutable = false;
boolean isAppKnown = ((cncstr.indexOf("host=localhost") > 0) || (cncstr.indexOf("pipe,name=") > 0));
isAppKnown &= !((String) param.get("AppExecutionCommand")).equals("");
- if (isAppKnown) {
+ if (isAppKnown)
+ {
dbg("Local Connection trying to start the Office");
//ensure that a pending officewatcher gets finished before a new
//office is started
final OfficeWatcher ow_old = (OfficeWatcher) param.get("Watcher");
- if (ow_old != null) {
+ if (ow_old != null)
+ {
ow_old.finish = true;
}
@@ -192,8 +222,9 @@ public class OfficeProvider implements AppProvider {
// validate the AppExecutionCommand, but try it out anyway.
// keep the error message for later.
errorMessage =
- util.utils.validateAppExecutionCommand(cmd, (String) param.get("OperatingSystem"));
- if (errorMessage.startsWith("Error")) {
+ util.utils.validateAppExecutionCommand(cmd, (String) param.get("OperatingSystem"));
+ if (errorMessage.startsWith("Error"))
+ {
System.out.println(errorMessage);
return null;
}
@@ -201,7 +232,7 @@ public class OfficeProvider implements AppProvider {
final DynamicClassLoader dcl = new DynamicClassLoader();
final LogWriter log = (LogWriter) dcl.getInstance(
- (String) param.get("LogWriter"));
+ (String) param.get("LogWriter"));
//create empty entry
final DescEntry Entry = new DescEntry();
@@ -220,7 +251,8 @@ public class OfficeProvider implements AppProvider {
final ProcessHandler ph = new ProcessHandler(cmd, (PrintWriter) log);
isExecutable = ph.executeAsynchronously();
- if (isExecutable) {
+ if (isExecutable)
+ {
param.put("AppProvider", ph);
final OfficeWatcher ow = new OfficeWatcher(param);
param.put("Watcher", ow);
@@ -253,31 +285,39 @@ public class OfficeProvider implements AppProvider {
{
Thread.sleep(k * 500);
}
- catch (InterruptedException ex){ }
- }
+ catch (InterruptedException ex)
+ {
+ }
+ }
k++;
}
- if (msf == null) {
+ if (msf == null)
+ {
System.out.println("Exception while connecting.\n" + exConnectFailed);
- if (exc != null) {
+ if (exc != null)
+ {
System.out.println(exc);
}
- if (bAppExecutionHasWarning) {
+ if (bAppExecutionHasWarning)
+ {
System.out.println(errorMessage);
}
- } else if (isExecutable)
+ }
+ else if (isExecutable)
{
- if (! param.getBool(util.PropertyName.DONT_BACKUP_USERLAYER))
+ if (!param.getBool(util.PropertyName.DONT_BACKUP_USERLAYER))
{
backupUserLayer(param, msf);
}
}
- } else {
- System.out.println("Could not connect an Office and cannot start one.\n".
- concat("please start an office with following parameter:\n").
+ }
+ else
+ {
+ System.out.println("Could not connect an Office and cannot start one.\n".concat("please start an office with following parameter:\n").
concat("\nsoffice -accept=").concat((String) param.get("ConnectionString")).concat(";urp;\n"));
- if (bAppExecutionHasWarning) {
+ if (bAppExecutionHasWarning)
+ {
System.out.println(errorMessage);
}
}
@@ -288,16 +328,23 @@ public class OfficeProvider implements AppProvider {
/**
* Connect an Office
+ * @param connectStr
+ * @return
+ * @throws com.sun.star.uno.Exception
+ * @throws com.sun.star.uno.RuntimeException
+ * @throws com.sun.star.connection.NoConnectException
+ * @throws Exception
*/
protected static XMultiServiceFactory connect(String connectStr)
- throws com.sun.star.uno.Exception,
- com.sun.star.uno.RuntimeException,
- com.sun.star.connection.NoConnectException,
- Exception {
+ throws com.sun.star.uno.Exception,
+ com.sun.star.uno.RuntimeException,
+ com.sun.star.connection.NoConnectException,
+ Exception
+ {
// Get component context
final XComponentContext xcomponentcontext = com.sun.star.comp.helper.Bootstrap.createInitialComponentContext(
- null);
+ null);
// initial serviceManager
final XMultiComponentFactory xLocalServiceManager = xcomponentcontext.getServiceManager();
@@ -305,20 +352,21 @@ public class OfficeProvider implements AppProvider {
// create a connector, so that it can contact the office
// XUnoUrlResolver urlResolver = UnoUrlResolver.create(xcomponentcontext);
final Object xUrlResolver = xLocalServiceManager.createInstanceWithContext(
- "com.sun.star.bridge.UnoUrlResolver", xcomponentcontext);
+ "com.sun.star.bridge.UnoUrlResolver", xcomponentcontext);
final XUnoUrlResolver urlResolver = (XUnoUrlResolver) UnoRuntime.queryInterface(
- XUnoUrlResolver.class, xUrlResolver);
+ XUnoUrlResolver.class, xUrlResolver);
final Object rInitialObject = urlResolver.resolve(connectStr);
XMultiServiceFactory xMSF = null;
- if (rInitialObject != null) {
+ if (rInitialObject != null)
+ {
debug = true;
dbg("resolved url");
xMSF = (XMultiServiceFactory) UnoRuntime.queryInterface(
- XMultiServiceFactory.class, rInitialObject);
+ XMultiServiceFactory.class, rInitialObject);
}
return xMSF;
@@ -330,18 +378,21 @@ public class OfficeProvider implements AppProvider {
* @param closeIfPossible If true, close even if
* it was running before the test
*/
- public boolean closeExistingOffice(lib.TestParameters param, boolean closeIfPossible) {
+ public boolean closeExistingOffice(lib.TestParameters param, boolean closeIfPossible)
+ {
XMultiServiceFactory msf = (XMultiServiceFactory) param.getMSF();
final boolean alreadyConnected = (msf != null);
debug = param.getBool(PropertyName.DEBUG_IS_ACTIVE);
- if (alreadyConnected) {
+ if (alreadyConnected)
+ {
dbg("try to get ProcessHandler");
final ProcessHandler ph = (ProcessHandler) param.get("AppProvider");
- if (ph != null) {
+ if (ph != null)
+ {
dbg("ProcessHandler != null");
disposeOffice(msf, param);
@@ -351,26 +402,35 @@ public class OfficeProvider implements AppProvider {
final OfficeWatcher ow = (OfficeWatcher) param.get("Watcher");
- if ((ow != null) && ow.isAlive()) {
+ if ((ow != null) && ow.isAlive())
+ {
dbg("OfficeWatcher will be finished");
ow.finish = true;
- } else {
+ }
+ else
+ {
dbg("OfficeWatcher seems to be finished");
}
return true;
- } else {
- if (closeIfPossible) {
+ }
+ else
+ {
+ if (closeIfPossible)
+ {
return disposeOffice(msf, param);
}
}
- } else {
+ }
+ else
+ {
final String cncstr = "uno:" + param.get("ConnectionString") +
- ";urp;StarOffice.ServiceManager";
+ ";urp;StarOffice.ServiceManager";
dbg("try to connect office");
msf = connectOffice(cncstr);
- if (closeIfPossible) {
+ if (closeIfPossible)
+ {
return disposeOffice(msf, param);
}
}
@@ -378,23 +438,31 @@ public class OfficeProvider implements AppProvider {
return true;
}
- private XMultiServiceFactory connectOffice(String cncstr) {
+ private XMultiServiceFactory connectOffice(String cncstr)
+ {
XMultiServiceFactory msf = null;
String exc = "";
debug = true;
dbg("trying to connect to " + cncstr);
- try {
+ try
+ {
msf = connect(cncstr);
- } catch (com.sun.star.uno.Exception ue) {
+ }
+ catch (com.sun.star.uno.Exception ue)
+ {
exc = ue.getMessage();
- } catch (java.lang.Exception je) {
+ }
+ catch (java.lang.Exception je)
+ {
exc = je.getMessage();
}
- if (debug && exc != null && exc.length() != 0) {
- if (exc == null) {
+ if (debug && exc != null && exc.length() != 0)
+ {
+ if (exc == null)
+ {
exc = "";
}
dbg("Could not connect an Office. " + exc);
@@ -404,34 +472,42 @@ public class OfficeProvider implements AppProvider {
}
private synchronized boolean disposeOffice(XMultiServiceFactory msf,
- TestParameters param) {
+ TestParameters param)
+ {
XDesktop desk = null;
debug = param.getBool(PropertyName.DEBUG_IS_ACTIVE);
boolean result = true;
- if (msf != null) {
+ if (msf != null)
+ {
// disable QuickStarter
- try {
+ try
+ {
Object quickStarter = msf.createInstance("com.sun.star.office.Quickstart");
XFastPropertySet fps = (XFastPropertySet) UnoRuntime.queryInterface(XFastPropertySet.class, quickStarter);
fps.setFastPropertyValue(0, false);
- } catch (com.sun.star.uno.Exception ex) {
+ }
+ catch (com.sun.star.uno.Exception ex)
+ {
dbg("ERROR: Could not disable QuickStarter: " + ex.toString());
}
- try {
+ try
+ {
desk = (XDesktop) UnoRuntime.queryInterface(XDesktop.class,
- msf.createInstance(
- "com.sun.star.frame.Desktop"));
+ msf.createInstance(
+ "com.sun.star.frame.Desktop"));
msf = null;
- if (desk != null) {
+ if (desk != null)
+ {
final boolean allClosed = closeAllWindows(desk);
- if (!allClosed) {
+ if (!allClosed)
+ {
dbg("Couldn't close all office windows!");
}
@@ -440,16 +516,23 @@ public class OfficeProvider implements AppProvider {
desk.terminate();
dbg("Desktop terminated");
- try {
+ try
+ {
final int closeTime = param.getInt(util.PropertyName.OFFICE_CLOSE_TIME_OUT);
dbg("the Office has " + closeTime / 1000 + " seconds for closing...");
Thread.sleep(closeTime);
- } catch (java.lang.InterruptedException e) {
+ }
+ catch (java.lang.InterruptedException e)
+ {
}
}
- } catch (com.sun.star.uno.Exception ue) {
+ }
+ catch (com.sun.star.uno.Exception ue)
+ {
result = false;
- } catch (com.sun.star.lang.DisposedException ue) {
+ }
+ catch (com.sun.star.lang.DisposedException ue)
+ {
result = false;
}
}
@@ -473,11 +556,13 @@ public class OfficeProvider implements AppProvider {
final ProcessHandler ph = (ProcessHandler) param.get("AppProvider");
- if (ph != null) {
+ if (ph != null)
+ {
// dispose watcher in case it's still running.
final OfficeWatcher ow = (OfficeWatcher) param.get("Watcher");
- if ((ow != null) && ow.isAlive()) {
+ if ((ow != null) && ow.isAlive())
+ {
ow.finish = true;
}
@@ -487,17 +572,21 @@ public class OfficeProvider implements AppProvider {
param.remove("AppProvider");
param.remove("ServiceFactory");
- if (! param.getBool(util.PropertyName.DONT_BACKUP_USERLAYER))
+ if (!param.getBool(util.PropertyName.DONT_BACKUP_USERLAYER))
{
//copy user_backup into user layer
- try {
+ try
+ {
final String userLayer = (String) param.get("userLayer");
final String copyLayer = (String) param.get("copyLayer");
if (userLayer != null && copyLayer != null)
{
final File copyFile = new File(copyLayer);
dbg("copy '" + copyFile + "' -> '" + userLayer + "'");
- FileTools.copyDirectory(copyFile, new File(userLayer), new String[]{"temp"});
+ FileTools.copyDirectory(copyFile, new File(userLayer), new String[]
+ {
+ "temp"
+ });
dbg("copy '" + copyFile + "' -> '" + userLayer + "' finished");
// remove all user_backup folder in temp dir
@@ -518,46 +607,63 @@ public class OfficeProvider implements AppProvider {
return result;
}
- protected boolean closeAllWindows(XDesktop desk) {
+ protected boolean closeAllWindows(XDesktop desk)
+ {
final XEnumerationAccess compEnumAccess = desk.getComponents();
final XEnumeration compEnum = compEnumAccess.createEnumeration();
boolean res = true;
- try {
- while (compEnum.hasMoreElements()) {
+ try
+ {
+ while (compEnum.hasMoreElements())
+ {
final XCloseable closer = (XCloseable) UnoRuntime.queryInterface(
- XCloseable.class,
- compEnum.nextElement());
+ XCloseable.class,
+ compEnum.nextElement());
- if (closer != null) {
+ if (closer != null)
+ {
closer.close(true);
}
}
- } catch (com.sun.star.util.CloseVetoException cve) {
+ }
+ catch (com.sun.star.util.CloseVetoException cve)
+ {
res = false;
- } catch (com.sun.star.container.NoSuchElementException nsee) {
+ }
+ catch (com.sun.star.container.NoSuchElementException nsee)
+ {
res = false;
- } catch (com.sun.star.lang.WrappedTargetException wte) {
+ }
+ catch (com.sun.star.lang.WrappedTargetException wte)
+ {
res = false;
}
return res;
}
- public static XStringSubstitution createStringSubstitution(XMultiServiceFactory xMSF) {
+ public static XStringSubstitution createStringSubstitution(XMultiServiceFactory xMSF)
+ {
Object xPathSubst = null;
- try {
+ try
+ {
xPathSubst = xMSF.createInstance(
- "com.sun.star.util.PathSubstitution");
- } catch (com.sun.star.uno.Exception e) {
+ "com.sun.star.util.PathSubstitution");
+ }
+ catch (com.sun.star.uno.Exception e)
+ {
e.printStackTrace();
}
- if (xPathSubst != null) {
+ if (xPathSubst != null)
+ {
return (XStringSubstitution) UnoRuntime.queryInterface(
- XStringSubstitution.class, xPathSubst);
- } else {
+ XStringSubstitution.class, xPathSubst);
+ }
+ else
+ {
return null;
}
}
@@ -565,8 +671,11 @@ public class OfficeProvider implements AppProvider {
/**
* converts directory without 'file:///' prefix.
* and System dependend file separator
+ * @param dir
+ * @return
*/
- public static String getDirSys(String dir) {
+ public static String getDirSys(String dir)
+ {
String sysDir = "";
final int idx = dir.indexOf("file://");
@@ -574,26 +683,34 @@ public class OfficeProvider implements AppProvider {
final int idx2 = dir.indexOf("file:///");
// remove leading 'file://'
- if (idx < 0) {
+ if (idx < 0)
+ {
sysDir = dir;
- } else {
+ }
+ else
+ {
sysDir = dir.substring("file://".length());
}
sysDir = utils.replaceAll13(sysDir, "%20", " ");
// append '/' if not there (e.g. linux)
- if (sysDir.charAt(sysDir.length() - 1) != '/') {
+ if (sysDir.charAt(sysDir.length() - 1) != '/')
+ {
sysDir += "/";
}
// remove leading '/' and replace others with '\' on windows machines
final String sep = System.getProperty("file.separator");
- if (sep.equalsIgnoreCase("\\")) {
- if (!(idx2 < 0)) {
+ if (sep.equalsIgnoreCase("\\"))
+ {
+ if (!(idx2 < 0))
+ {
sysDir = sysDir.substring(1);
- } else {
+ }
+ else
+ {
//network path
sysDir = "//" + sysDir;
}
@@ -611,27 +728,42 @@ public class OfficeProvider implements AppProvider {
* @param msf the <CODE>MultiServiceFactory</CODE>
* @param param the <CODE>TestParameters</CODE>
*/
- private static void makeAppExecCommand(XMultiServiceFactory msf, TestParameters param) {
+ private static void makeAppExecCommand(XMultiServiceFactory msf, TestParameters param)
+ {
debug = param.getBool(PropertyName.DEBUG_IS_ACTIVE);
// get existing AppExecutionCommand if available, else empty string
String command = (String) param.get(util.PropertyName.APP_EXECUTION_COMMAND);
- final String connectionString = (String) param.get(util.PropertyName.CONNECTION_STRING);
+ String connectionString;
+ if (param.getBool(util.PropertyName.USE_PIPE_CONNECTION) == true)
+ {
+ // This is the default behaviour
+ connectionString = (String) param.get(util.PropertyName.PIPE_CONNECTION_STRING);
+ }
+ else
+ {
+ // is used if UsePipeConnection=false
+ connectionString = (String) param.get(util.PropertyName.CONNECTION_STRING);
+ }
String sysBinDir = "";
- try {
+ try
+ {
sysBinDir = utils.getSystemURL(utils.expandMacro(msf, "$SYSBINDIR"));
- } catch (java.lang.Exception e) {
+ }
+ catch (java.lang.Exception e)
+ {
dbg("could not get system binary directory");
return;
}
// does the existing command show to the connected office?
- if (command.indexOf(sysBinDir) == -1) {
+ if (command.indexOf(sysBinDir) == -1)
+ {
command = sysBinDir + System.getProperty("file.separator") + "soffice" +
- " -norestore -accept=" + connectionString + ";urp;";
+ " -norestore -accept=" + connectionString + ";urp;";
}
dbg("update AppExecutionCommand: " + command);
@@ -639,42 +771,53 @@ public class OfficeProvider implements AppProvider {
param.put(util.PropertyName.APP_EXECUTION_COMMAND, command);
}
- private static void dbg(String message) {
- if (debug) {
+ private static void dbg(String message)
+ {
+ if (debug)
+ {
System.out.println(utils.getDateTime() + "OfficeProvider: " + message);
}
}
- private class OfficeWatcherPing extends Thread {
+ private class OfficeWatcherPing extends Thread
+ {
private final OfficeWatcher ow;
private boolean bStop = false;
- public OfficeWatcherPing(OfficeWatcher ow) {
+ public OfficeWatcherPing(OfficeWatcher ow)
+ {
this.ow = ow;
}
- public void run() {
+ public void run()
+ {
System.out.println(utils.getDateTime() + "OfficeProvider:Owp: start ");
- while (!bStop) {
- System.out.println(utils.getDateTime() + "OfficeProvider:Owp: ping ");
- ow.ping();
- try {
+ while (!bStop)
+ {
+ System.out.println(utils.getDateTime() + "OfficeProvider:Owp: ping ");
+ ow.ping();
+ try
+ {
System.out.println(utils.getDateTime() + "OfficeProvider:Owp: sleep ");
OfficeWatcherPing.sleep(1000); // 5000
- } catch (InterruptedException ex) {
+ }
+ catch (InterruptedException ex)
+ {
ex.printStackTrace();
}
}
}
- public void finish() {
- synchronized (this) {
+ public void finish()
+ {
+ synchronized(this)
+ {
bStop = true;
- System.out.println(utils.getDateTime() + "OfficeProvider:Owp: stop ");
+ System.out.println(utils.getDateTime() + "OfficeProvider:Owp: stop ");
notify();
}
diff --git a/qadevOOo/runner/helper/ProcessHandler.java b/qadevOOo/runner/helper/ProcessHandler.java
index c1892094d093..9939a73bf215 100644
--- a/qadevOOo/runner/helper/ProcessHandler.java
+++ b/qadevOOo/runner/helper/ProcessHandler.java
@@ -51,7 +51,8 @@ import util.utils;
* This class is currently used by ProcesHandler
* internally only.
*/
-class Pump extends Thread {
+class Pump extends Thread
+{
private LineNumberReader reader;
private String pref;
@@ -69,23 +70,29 @@ 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) {
- this.pref = outPrefix == null ? "" : outPrefix;
+ public Pump(InputStream is, PrintWriter log, String outPrefix)
+ {
+ this.pref = (outPrefix == null) ? "" : outPrefix;
reader = new LineNumberReader(new InputStreamReader(is));
this.log = log;
start();
}
- public void run() {
- try {
+ public void run()
+ {
+ try
+ {
String line = reader.readLine();
- while (line != null) {
+ while (line != null)
+ {
log.println(pref + line);
log.flush();
buf.append(line).append('\n');
line = reader.readLine();
}
- } catch (java.io.IOException e) {
+ }
+ catch (java.io.IOException e)
+ {
log.println(pref + "Exception occured: " + e);
}
}
@@ -93,7 +100,8 @@ class Pump extends Thread {
/**
* Returns the text collected from input stream.
*/
- public String getStringBuffer() {
+ public String getStringBuffer()
+ {
return buf.toString();
}
}
@@ -105,7 +113,8 @@ class Pump extends Thread {
* execution. If you need to execute the same command again you
* should create a new instance for this.
*/
-public class ProcessHandler {
+public class ProcessHandler
+{
private String cmdLine;
private String[] cmdLineArray;
@@ -121,7 +130,7 @@ public class ProcessHandler {
private Pump stdout = null;
private Pump stderr = null;
private PrintStream stdIn = null;
- private Process proc = null;
+ private Process m_aProcess = null;
private TestParameters param = null;
private boolean debug = false;
@@ -131,7 +140,8 @@ public class ProcessHandler {
* of external command is printed to stdout.
* @param cmdLine
*/
- public ProcessHandler(String cmdLine) {
+ public ProcessHandler(String cmdLine)
+ {
this(cmdLine, null, null, null, 0);
}
@@ -142,7 +152,8 @@ public class ProcessHandler {
* of external command is printed to stdout.
* @param cmdLines
*/
- public ProcessHandler(String[] cmdLines) {
+ public ProcessHandler(String[] cmdLines)
+ {
this(null, null, null, null, 0);
cmdLineArray = cmdLines;
}
@@ -157,7 +168,8 @@ public class ProcessHandler {
* @param envVars
* @see java.lang.Runtime exec(String[], String[])
*/
- public ProcessHandler(String[] cmdLines, String[] envVars) {
+ public ProcessHandler(String[] cmdLines, String[] envVars)
+ {
this(null, null, null, envVars, 0);
cmdLineArray = cmdLines;
}
@@ -171,7 +183,8 @@ public class ProcessHandler {
* @param cmdLines
* @param workDir
*/
- public ProcessHandler(String[] cmdLines, File workDir) {
+ public ProcessHandler(String[] cmdLines, File workDir)
+ {
this(null, null, workDir, null, 0);
cmdLineArray = cmdLines;
@@ -185,7 +198,8 @@ public class ProcessHandler {
* @param log
* @param workDir
*/
- public ProcessHandler(String[] cmdLines, PrintWriter log, File workDir) {
+ public ProcessHandler(String[] cmdLines, PrintWriter log, File workDir)
+ {
this(null, log, workDir, null, 0);
cmdLineArray = cmdLines;
}
@@ -197,7 +211,8 @@ public class ProcessHandler {
* @param cmdLine
* @param log
*/
- public ProcessHandler(String cmdLine, PrintWriter log) {
+ public ProcessHandler(String cmdLine, PrintWriter log)
+ {
this(cmdLine, log, null, null, 0);
}
@@ -206,7 +221,8 @@ public class ProcessHandler {
* @param cmdLine
* @param timeOut
*/
- public ProcessHandler(String cmdLine, int timeOut) {
+ public ProcessHandler(String cmdLine, int timeOut)
+ {
this(cmdLine, null, null, null, timeOut);
}
@@ -218,7 +234,8 @@ public class ProcessHandler {
* @param cmdLine
* @param workDir
*/
- public ProcessHandler(String cmdLine, File workDir) {
+ public ProcessHandler(String cmdLine, File workDir)
+ {
this(cmdLine, null, workDir, null, 0);
}
@@ -230,7 +247,8 @@ public class ProcessHandler {
* @param log
* @param workDir
*/
- public ProcessHandler(String cmdLine, PrintWriter log, File workDir) {
+ public ProcessHandler(String cmdLine, PrintWriter log, File workDir)
+ {
this(cmdLine, log, workDir, null, 0);
}
@@ -246,7 +264,8 @@ public class ProcessHandler {
* @param workDir
* @param envVars
*/
- public ProcessHandler(String cmdLine, PrintWriter log, File workDir, String[] envVars) {
+ public ProcessHandler(String cmdLine, PrintWriter log, File workDir, String[] envVars)
+ {
this(cmdLine, log, workDir, envVars, 0);
}
@@ -278,15 +297,19 @@ public class ProcessHandler {
*
*
*/
- public ProcessHandler(String cmdLine, PrintWriter log, File workDir, String[] envVars, long timeOut) {
+ public ProcessHandler(String cmdLine, PrintWriter log, File workDir, String[] envVars, long timeOut)
+ {
this.cmdLine = cmdLine;
this.workDir = workDir;
this.log = log;
this.cmdLine = cmdLine;
this.envVars = envVars;
- if (log == null) {
+ if (log == null)
+ {
this.log = new PrintWriter(new OutputStreamWriter(System.out));
- } else {
+ }
+ else
+ {
this.log = log;
}
this.mTimeOut = timeOut;
@@ -307,13 +330,17 @@ public class ProcessHandler {
* @see lib.TestParameters
* @see helper.OfficeWatcher
*/
- public ProcessHandler(String[] commands, PrintWriter log, File workDir, int shortWait, TestParameters param) {
+ public ProcessHandler(String[] commands, PrintWriter log, File workDir, int shortWait, TestParameters param)
+ {
this(null, log, workDir, null, 0);
this.cmdLineArray = commands;
this.param = param;
- if (shortWait != 0) {
+ if (shortWait != 0)
+ {
this.mTimeOut = shortWait;
- } else {
+ }
+ else
+ {
this.mTimeOut = (long) (param.getInt(PropertyName.TIME_OUT) / 1.3);
}
debug = param.getBool(PropertyName.DEBUG_IS_ACTIVE);
@@ -325,7 +352,8 @@ public class ProcessHandler {
* caused by <CODE>OfficeWatcher</CODE>, the OfficeWatcher get frequently a ping.
* @see helper.OfficeWatcher
*/
- public void runCommand() {
+ public void runCommand()
+ {
boolean changedText = true;
int count = 0;
@@ -334,25 +362,31 @@ public class ProcessHandler {
this.executeAsynchronously();
OfficeWatcher ow = null;
- if (param != null) {
+ if (param != null)
+ {
ow = (OfficeWatcher) param.get(PropertyName.OFFICE_WATCHER);
}
- while (!this.isFinished() && changedText) {
+ while (!this.isFinished() && changedText)
+ {
count++;
- if (ow != null) {
+ if (ow != null)
+ {
ow.ping();
}
dbg("runCommand: waiting " + mTimeOut / 1000 + " seconds while command execution is ongoing... " + count);
shortWait(mTimeOut);
//waitFor(mTimeOut);
- if (ow != null) {
+ if (ow != null)
+ {
ow.ping();
}
// check for changes in the output stream. If there are no changes, the process maybe hangs
- if (!this.isFinished()) {
- if (this.getOutputText().length() == memText.length()) {
+ if (!this.isFinished())
+ {
+ if (this.getOutputText().length() == memText.length())
+ {
changedText = false;
dbg("runCommand Could not detect changes in output stream!!!");
@@ -361,17 +395,20 @@ public class ProcessHandler {
}
}
- if (!this.isFinished()) {
+ if (!this.isFinished())
+ {
dbg("runCommand Process ist not finished but there are no changes in output stream.");
this.kill();
}
}
- public boolean isTimedOut() {
+ public boolean isTimedOut()
+ {
return mbTimedOut;
}
- private void setTimedOut(boolean bTimedOut) {
+ private void setTimedOut(boolean bTimedOut)
+ {
mbTimedOut = bTimedOut;
}
@@ -383,7 +420,8 @@ public class ProcessHandler {
* started and correcly exits (exit code doesn't affect
* to this result).
*/
- public boolean executeSynchronously() {
+ public boolean executeSynchronously()
+ {
execute();
return waitFor(mTimeOut);
}
@@ -396,34 +434,48 @@ public class ProcessHandler {
* @return <code>true</code> if process was successfully
* started.
*/
- public boolean executeAsynchronously() {
+ public boolean executeAsynchronously()
+ {
execute();
return isStarted();
}
- public synchronized void kill() {
- if (!isStarted()) {
+ public synchronized void kill()
+ {
+ if (!isStarted())
+ {
return;
}
boolean exit = false;
int counter = 1;
- while (counter < 3 && !exit) {
- proc.destroy();
+ while (counter < 3 && !exit)
+ {
+ m_aProcess.destroy();
- try {
+ try
+ {
Thread.sleep(1000 * counter); // 5000
- } catch (java.lang.InterruptedException e) {
}
- try {
- final int exit_Value = proc.exitValue();
- if (exit_Value < 1) {
+ catch (java.lang.InterruptedException e)
+ {
+ }
+ try
+ {
+ final int exit_Value = m_aProcess.exitValue();
+ if (exit_Value < 1)
+ {
exit = true;
- } else {
+ }
+ else
+ {
counter++;
}
dbg("kill: process closed with exit code " + exit_Value);
- } catch (java.lang.IllegalThreadStateException e) {
- if (counter < 3) {
+ }
+ catch (java.lang.IllegalThreadStateException e)
+ {
+ if (counter < 3)
+ {
dbg("kill: Couldn't close process after " + counter + " attempts, trying again");
}
counter++;
@@ -432,45 +484,63 @@ public class ProcessHandler {
isStarted = false;
}
- protected void execute() {
- if (isStarted()) {
+ protected void execute()
+ {
+ if (isStarted())
+ {
throw new RuntimeException(
- "The process handler has already been executed.");
+ "The process handler has already been executed.");
}
final Runtime runtime = Runtime.getRuntime();
- try {
- if (cmdLine == null) {
+ try
+ {
+ if (cmdLine == null)
+ {
log.print(utils.getDateTime() + "execute: Starting command from array: ");
- for (int i = 0; i < cmdLineArray.length; i++) {
+ for (int i = 0; i < cmdLineArray.length; i++)
+ {
log.print(cmdLineArray[i]);
log.print(" ");
}
log.println("");
- proc = runtime.exec(cmdLineArray, envVars);
- } else {
- if (workDir != null) {
+ m_aProcess = runtime.exec(cmdLineArray, envVars);
+ }
+ else
+ {
+ if (workDir != null)
+ {
log.println(utils.getDateTime() + "execute: Starting command: " + cmdLine + " " +
- workDir.getAbsolutePath());
- proc = runtime.exec(cmdLine, envVars, workDir);
- } else {
+ workDir.getAbsolutePath());
+ m_aProcess = runtime.exec(cmdLine, envVars, workDir);
+ }
+ else
+ {
log.println(utils.getDateTime() + "execute: Starting command: " + cmdLine);
- proc = runtime.exec(cmdLine, envVars);
+ m_aProcess = runtime.exec(cmdLine, envVars);
}
}
isStarted = true;
- } catch (java.io.IOException e) {
- if (cmdLine == null) {
+ }
+ catch (java.io.IOException e)
+ {
+ if (cmdLine == null)
+ {
log.println(utils.getDateTime() + "execute: The command array can't be started: " + e);
- } else {
+ }
+ else
+ {
log.println(utils.getDateTime() + "execute: The command " + cmdLine + " can't be started: " + e);
}
return;
}
dbg("execute: pump io-streams");
- stdout = new Pump(proc.getInputStream(), log, "out > ");
- stderr = new Pump(proc.getErrorStream(), log, "err > ");
- stdIn = new PrintStream(proc.getOutputStream());
+ stdout = new Pump(m_aProcess.getInputStream(), log, "out > ");
+ stderr = new Pump(m_aProcess.getErrorStream(), log, "err > ");
+ stdIn = new PrintStream(m_aProcess.getOutputStream());
+
+ // int nExitValue = m_aProcess.exitValue();
+ // int dummy = 0;
dbg("execute: flush io-streams");
@@ -485,7 +555,8 @@ public class ProcessHandler {
* @return <code>true</code> if process correctly exited
* (exit code doesn't affect to this result).
*/
- public boolean waitFor() {
+ public boolean waitFor()
+ {
return waitFor(0);
}
@@ -507,49 +578,70 @@ public class ProcessHandler {
* @return <code>true</code> if process correctly exited
* (exit code doesn't affect to this result).
*/
- public boolean waitFor(long timeout) {
- if (isFinished()) {
+ public boolean waitFor(long timeout)
+ {
+ if (isFinished())
+ {
return true;
}
- if (!isStarted()) {
+ if (!isStarted())
+ {
return false;
}
- if (timeout == 0) {
- try {
- proc.waitFor();
- } catch (InterruptedException e) {
+ if (timeout == 0)
+ {
+ try
+ {
+ m_aProcess.waitFor();
+ }
+ catch (InterruptedException e)
+ {
log.println("The process was interrupted: " + e);
}
isFinished = true;
- try {
- exitValue = proc.exitValue();
- } catch (IllegalThreadStateException e) {
+ try
+ {
+ exitValue = m_aProcess.exitValue();
+ }
+ catch (IllegalThreadStateException e)
+ {
}
- } else {
- try {
- while (!isFinished && timeout > 0) {
+ }
+ else
+ {
+ try
+ {
+ while (!isFinished && timeout > 0)
+ {
isFinished = true;
Thread.sleep(1000);
timeout -= 1000;
- try {
- exitValue = proc.exitValue(); // throws exception if not finished
- } catch (IllegalThreadStateException e) {
+ try
+ {
+ exitValue = m_aProcess.exitValue(); // throws exception if not finished
+ }
+ catch (IllegalThreadStateException e)
+ {
isFinished = false;
}
}
- if (timeout < 0) {
+ if (timeout < 0)
+ {
setTimedOut(true);
log.println("The process has timed out!");
}
- } catch (InterruptedException ex) {
+ }
+ catch (InterruptedException ex)
+ {
log.println("The process was interrupted: " + ex);
}
}
- if (!isFinished) {
+ if (!isFinished)
+ {
log.println("Going to destroy the process!!");
- proc.destroy();
+ m_aProcess.destroy();
log.println("Process has been destroyed!");
}
// Removed as hung up in SDK test 'PathSettings'
@@ -561,12 +653,15 @@ public class ProcessHandler {
return isFinished();
}
- protected void flushInput() {
- if (stdIn == null) {
+ protected void flushInput()
+ {
+ if (stdIn == null)
+ {
return;
}
- synchronized (stdInBuff) {
+ synchronized(stdInBuff)
+ {
stdIn.print(stdInBuff);
stdIn.flush();
stdInBuff = "";
@@ -577,10 +672,14 @@ public class ProcessHandler {
* Returns the text output by external command to stdout.
* @return the text output by external command to stdout
*/
- public String getOutputText() {
- if (stdout == null) {
+ public String getOutputText()
+ {
+ if (stdout == null)
+ {
return "";
- } else {
+ }
+ else
+ {
return stdout.getStringBuffer();
}
}
@@ -589,10 +688,14 @@ public class ProcessHandler {
* Returns the text output by external command to stderr.
* @return the text output by external command to stderr
*/
- public String getErrorText() {
- if (stderr == null) {
+ public String getErrorText()
+ {
+ if (stderr == null)
+ {
return "";
- } else {
+ }
+ else
+ {
return stderr.getStringBuffer();
}
}
@@ -607,7 +710,8 @@ public class ProcessHandler {
* and transfered to command when it will be started.
* @param str
*/
- public void printInputText(String str) {
+ public void printInputText(String str)
+ {
stdInBuff += str;
flushInput();
}
@@ -619,7 +723,8 @@ public class ProcessHandler {
* @return <code>true</code> if the external command was
* found and successfully started.
*/
- public boolean isStarted() {
+ public boolean isStarted()
+ {
return isStarted;
}
@@ -630,7 +735,8 @@ public class ProcessHandler {
* @return <code>true</code> if the command correctly starts,
* exits and was not interrupted due to timeout.
*/
- public boolean isFinished() {
+ public boolean isFinished()
+ {
return isFinished;
}
@@ -640,11 +746,15 @@ public class ProcessHandler {
* @return exit code of command if it was finished,
* -1 if not.
*/
- public int getExitCode() {
- try {
- exitValue = proc.exitValue();
- } catch (Exception e) {
- //System.out.println("No ExitValue available");
+ public int getExitCode()
+ {
+ try
+ {
+ exitValue = m_aProcess.exitValue();
+ }
+ catch (Exception e)
+ {
+ //System.out.println("No ExitValue available");
}
return exitValue;
@@ -653,16 +763,22 @@ public class ProcessHandler {
/** Causes the thread to sleep some time.
* @param milliseconds
*/
- public static void shortWait(long milliseconds) {
- try {
+ public static void shortWait(long milliseconds)
+ {
+ try
+ {
Thread.sleep(milliseconds);
- } catch (InterruptedException e) {
+ }
+ catch (InterruptedException e)
+ {
System.out.println("While waiting :" + e);
}
}
- private void dbg(String message) {
- if (debug) {
+ private void dbg(String message)
+ {
+ if (debug)
+ {
log.println(utils.getDateTime() + "PH." + message);
}
}
diff --git a/qadevOOo/runner/lib/TestParameters.java b/qadevOOo/runner/lib/TestParameters.java
index 6a98dee32926..be1987a8b22a 100644
--- a/qadevOOo/runner/lib/TestParameters.java
+++ b/qadevOOo/runner/lib/TestParameters.java
@@ -258,8 +258,11 @@ public class TestParameters extends Hashtable {
public TestParameters() {
//fill the propertyset
String user = System.getProperty("user.name");
- if ( user != null) {
- ConnectionString = "pipe,name=" + user;
+ if ( user != null)
+ {
+ String PipeConnectionString = "pipe,name=" + user;
+ put(PropertyName.PIPE_CONNECTION_STRING,PipeConnectionString);
+ put(PropertyName.USE_PIPE_CONNECTION, Boolean.TRUE);
}
put(PropertyName.CONNECTION_STRING,ConnectionString);
put(PropertyName.TEST_BASE,TestBase);
diff --git a/qadevOOo/runner/org/openoffice/Runner.java b/qadevOOo/runner/org/openoffice/Runner.java
index 305700b08ff6..47216ad8d815 100644
--- a/qadevOOo/runner/org/openoffice/Runner.java
+++ b/qadevOOo/runner/org/openoffice/Runner.java
@@ -27,16 +27,17 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
-
package org.openoffice;
+import java.util.Enumeration;
+import java.util.Properties;
+import java.util.StringTokenizer;
import lib.TestParameters;
import util.DynamicClassLoader;
import base.TestBase;
import helper.ClParser;
import helper.CfgParser;
-
/**
* The main class, will call ClParser and CfgParser to <br>
* fill the TestParameters.<br>
@@ -44,6 +45,7 @@ import helper.CfgParser;
*/
public class Runner
{
+
private static long m_nStartTime;
private static long getStartTime()
@@ -51,30 +53,32 @@ public class Runner
return m_nStartTime;
}
/*
- simple helper functions to start/stop a timer, to know how long a process need in milliseconds
+ simple helper functions to start/stop a timer, to know how long a process need in milliseconds
*/
+
private static long getTime()
- {
- return System.currentTimeMillis();
- }
+ {
+ return System.currentTimeMillis();
+ }
+
private static void setStartTime(long _nStartTime)
- {
- m_nStartTime = _nStartTime;
- }
+ {
+ m_nStartTime = _nStartTime;
+ }
/*
- return the time, which is done until last startTime()
+ return the time, which is done until last startTime()
*/
private static long meanTime(long _nCurrentTimer)
+ {
+ if (_nCurrentTimer == 0)
{
- if (_nCurrentTimer == 0)
- {
- System.out.println("Forgotten to initialise a start timer?");
- return 0;
- }
- long nMeanTime = getTime();
- return nMeanTime - _nCurrentTimer;
+ System.out.println("Forgotten to initialise a start timer?");
+ return 0;
}
+ long nMeanTime = getTime();
+ return nMeanTime - _nCurrentTimer;
+ }
private static String beautifyTime(long _nTime)
{
@@ -82,15 +86,107 @@ public class Runner
long min = (_nTime / (60 * 1000)) % 60;
long hour = _nTime / (60 * 60 * 1000);
StringBuffer aTime = new StringBuffer();
- aTime.append(helper.StringHelper.createValueString((int)hour, 2)).
- append(':').
- append(helper.StringHelper.createValueString((int)min, 2)).
- append(':').
- append(helper.StringHelper.createValueString((int)sec, 2));
+ aTime.append(helper.StringHelper.createValueString((int) hour, 2)).
+ append(':').
+ append(helper.StringHelper.createValueString((int) min, 2)).
+ append(':').
+ append(helper.StringHelper.createValueString((int) sec, 2));
return aTime.toString();
}
- public static void main(String[] args) {
+ /**
+ Helper to check if there are problems with Cygwin Path variables.
+ */
+ private static boolean checkVariableForCygwin(String _sVariable)
+ {
+ if (_sVariable == null)
+ {
+ return false;
+ }
+ if (_sVariable.startsWith("/cygdrive"))
+ {
+ return true;
+ }
+ return false;
+ }
+ private static boolean checkPathVariable(String _sPath, String delim)
+ {
+ String sPath = System.getProperty(_sPath);
+ if (sPath != null)
+ {
+ StringTokenizer aTokenEnum = new StringTokenizer(sPath, delim);
+ while (aTokenEnum.hasMoreElements())
+ {
+ String sToken = (String)aTokenEnum.nextElement();
+ if (checkVariableForCygwin(sToken))
+ {
+ System.err.println("ERROR: OOoRunner detect cygwin path in '" + _sPath + "'");
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ private static void checkAllVariablesForCygwinPath(TestParameters _aParams)
+ {
+ // ----- check all System.getProperty(key) variables -----
+ String sOsName = System.getProperty("os.name");
+ if (! sOsName.toLowerCase().startsWith("windows"))
+ {
+ // we need to check only on windows
+ return;
+ }
+
+ Properties aProps = System.getProperties();
+ Enumeration aEnum = aProps.propertyNames();
+ // Enumeration aEnum = aProps.elements(); // these are only the values
+ boolean bEmergencyStop = false;
+
+ while (aEnum.hasMoreElements())
+ {
+ String sKey = (String)aEnum.nextElement();
+ String sValue = System.getProperty(sKey);
+
+ if (checkVariableForCygwin(sValue))
+ {
+ System.err.println("ERROR: OOoRunner detect cygwin path in '" + sKey + ":=" + sValue + "'");
+ bEmergencyStop = true;
+ }
+ }
+
+ // ----- check path variables separatly -----
+ String sDelim = System.getProperty("path.separator");
+ bEmergencyStop |= checkPathVariable("java.library.path", sDelim);
+ bEmergencyStop |= checkPathVariable("java.class.path", sDelim);
+ bEmergencyStop |= checkPathVariable("sun.boot.class.path", sDelim);
+
+ // ----- check all TestParameters -----
+ aEnum = _aParams.keys();
+ while (aEnum.hasMoreElements())
+ {
+ String sKey = (String)aEnum.nextElement();
+ if (_aParams.get(sKey) instanceof String)
+ {
+ String sValue = (String)_aParams.get(sKey);
+
+ if (checkVariableForCygwin(sValue))
+ {
+ System.err.println("ERROR: OOoRunner detect cygwin path in '" + sKey + ":=" + sValue + "'");
+ bEmergencyStop = true;
+ }
+ }
+ }
+
+ if (bEmergencyStop)
+ {
+ System.exit(-1);
+ }
+ }
+
+ public static void main(String[] args)
+ {
+ System.out.println("OOoRunner Main()");
setStartTime(getTime());
@@ -122,11 +218,12 @@ public class Runner
//parse the commandline arguments
// TODO: no right error message, if no parameter given!
- cli.getCommandLineParameter(param,args);
+ cli.getCommandLineParameter(param, args);
Object tj = param.get("TestJob");
- if (tj==null) {
+ if (tj == null)
+ {
System.out.println("==========================================================================");
System.out.println("No TestJob given, please make sure that you ");
System.out.println("a.) called the OOoRunner with the paramter -o <job> or -sce <scenarioFile>");
@@ -136,10 +233,11 @@ public class Runner
System.exit(-1);
}
- System.out.println("TestJob: "+tj);
+ System.out.println("TestJob: " + tj);
+ String sName = "base." + (String) param.get("TestBase");
+ TestBase toExecute = (TestBase) dcl.getInstance(sName);
- TestBase toExecute = (TestBase) dcl.getInstance("base."+
- (String)param.get("TestBase"));
+ checkAllVariablesForCygwinPath(param);
boolean worked = toExecute.executeTest(param);
long nTime = meanTime(getStartTime());
@@ -149,12 +247,12 @@ public class Runner
if (!worked)
{
- System.out.println("Job "+param.get("TestJob")+" failed");
+ System.out.println("Job " + param.get("TestJob") + " failed");
System.exit(-1);
}
else
{
- System.out.println("Job "+param.get("TestJob")+" done");
+ System.out.println("Job " + param.get("TestJob") + " done");
System.exit(0);
}
}
diff --git a/qadevOOo/runner/util/DesktopTools.java b/qadevOOo/runner/util/DesktopTools.java
index 2e34e4de49d3..104bcdc309d3 100644
--- a/qadevOOo/runner/util/DesktopTools.java
+++ b/qadevOOo/runner/util/DesktopTools.java
@@ -245,6 +245,7 @@ public class DesktopTools {
{
throw new IllegalArgumentException("Document could not be loaded");
}
+
bringWindowToFront(oDoc);
return oDoc;
} //finish openNewDoc
@@ -254,6 +255,11 @@ public class DesktopTools {
* @param DocumentToClose the document to close
*/
public static void closeDoc(XInterface DocumentToClose) {
+ if (DocumentToClose == null)
+ {
+ return;
+ }
+
String kd = System.getProperty("KeepDocument");
if (kd != null ) {
System.out.println("The property 'KeepDocument' is set and so the document won't be disposed");
@@ -434,7 +440,7 @@ public class DesktopTools {
}
public static void bringWindowToFront(XComponent xComponent){
- System.out.println("DEBUG: bring to front xCompoent");
+ System.out.println("DEBUG: bring to front xComponent");
XModel xModel = (XModel) UnoRuntime.queryInterface(XModel.class, xComponent);
if (xModel != null){
bringWindowToFront(xModel);
diff --git a/qadevOOo/runner/util/PropertyName.java b/qadevOOo/runner/util/PropertyName.java
index 3f1b1e44d2c3..c77c07187288 100644
--- a/qadevOOo/runner/util/PropertyName.java
+++ b/qadevOOo/runner/util/PropertyName.java
@@ -46,6 +46,9 @@ public interface PropertyName {
* parameter name: "ConnectionString"
*/
final public static String CONNECTION_STRING = "ConnectionString";
+ final public static String PIPE_CONNECTION_STRING = "PipeConnectionString";
+ final public static String USE_PIPE_CONNECTION = "UsePipeConnection";
+
/**
* parameter name: "TestBase"
*/