summaryrefslogtreecommitdiff
path: root/qadevOOo/runner/helper
diff options
context:
space:
mode:
Diffstat (limited to 'qadevOOo/runner/helper')
-rw-r--r--qadevOOo/runner/helper/APIDescGetter.java985
-rw-r--r--qadevOOo/runner/helper/AppProvider.java55
-rw-r--r--qadevOOo/runner/helper/BuildEnvTools.java195
-rw-r--r--qadevOOo/runner/helper/CfgParser.java192
-rw-r--r--qadevOOo/runner/helper/ClParser.java193
-rw-r--r--qadevOOo/runner/helper/ComplexDescGetter.java194
-rw-r--r--qadevOOo/runner/helper/ConfigHelper.java348
-rw-r--r--qadevOOo/runner/helper/ConfigurationRead.java141
-rw-r--r--qadevOOo/runner/helper/ContextMenuInterceptor.java140
-rw-r--r--qadevOOo/runner/helper/CwsDataExchangeImpl.java157
-rw-r--r--qadevOOo/runner/helper/FileTools.java160
-rw-r--r--qadevOOo/runner/helper/InetTools.java88
-rw-r--r--qadevOOo/runner/helper/LoggingThread.java96
-rw-r--r--qadevOOo/runner/helper/OSHelper.java88
-rw-r--r--qadevOOo/runner/helper/ObjectInspectorModelImpl.java145
-rw-r--r--qadevOOo/runner/helper/OfficeProvider.java833
-rw-r--r--qadevOOo/runner/helper/OfficeWatcher.java132
-rw-r--r--qadevOOo/runner/helper/ParameterNotFoundException.java39
-rw-r--r--qadevOOo/runner/helper/ProcessHandler.java824
-rw-r--r--qadevOOo/runner/helper/PropertyHandlerFactroy.java49
-rw-r--r--qadevOOo/runner/helper/PropertyHandlerImpl.java258
-rwxr-xr-xqadevOOo/runner/helper/PropertyHelper.java81
-rw-r--r--qadevOOo/runner/helper/SimpleMailSender.java171
-rw-r--r--qadevOOo/runner/helper/StreamSimulator.java533
-rw-r--r--qadevOOo/runner/helper/StringHelper.java125
-rw-r--r--qadevOOo/runner/helper/URLHelper.java292
-rw-r--r--qadevOOo/runner/helper/UnoProvider.java165
-rw-r--r--qadevOOo/runner/helper/WindowListener.java78
-rw-r--r--qadevOOo/runner/helper/makefile.mk65
29 files changed, 6822 insertions, 0 deletions
diff --git a/qadevOOo/runner/helper/APIDescGetter.java b/qadevOOo/runner/helper/APIDescGetter.java
new file mode 100644
index 000000000000..9e980b273896
--- /dev/null
+++ b/qadevOOo/runner/helper/APIDescGetter.java
@@ -0,0 +1,985 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package helper;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.StringTokenizer;
+
+import share.DescEntry;
+import share.DescGetter;
+
+/**
+ * This is the Office-API specific DescGetter<br>
+ * <br>
+ * Examples:<br><br>
+ * -o sw.SwXBodyText<br>
+ * runs the module test of <B>Sw.SwXBodyText</B><br>
+ * <br>
+ * -o sw.SwXBodyText::com::sun::star::text::Text<br>
+ * runs only the interface test <B>com.sun.star.textText</B> of the module <B>Sw.SwXBodyText</B><br>
+ * <br>
+ * -o sw.SwXBodyText::com::sun::star::text::Text,com::sun::star::text::XSimpleText<br>
+ * runs only the interfaces test <B>com.sun.star.textText</B> and <B>com.sun.star.text.XSimpleText</B> of the module <B>Sw.SwXBodyText</B><br>
+ * <br>
+ * -p sw<br>
+ * runs all modules of the project <B>sw</B><br>
+ * <br>
+ * -p listall<br>
+ * lists all known module tests<br>
+ * <br>
+ * -sce SCENARIO_FILE<br>
+ * A scenario file is a property file which could cotain <B>-o</B> and <B>-p</B> properties<br>
+ * <br>
+ * -sce sw.SwXBodyText,sw.SwXBookmark<br>
+ * runs the module test of <B>Sw.SwXBodyText</B> and <B>sw.SwXBookmark</B><br>
+ */
+public class APIDescGetter extends DescGetter
+{
+
+ private static String fullJob = null;
+
+ /*
+ * gets the needed information about a StarOffice component
+ * @param descPath Path to the ComponentDescription
+ * @param entry contains the entry name, e.g. sw.SwXBodyText
+ * @param debug if true some debug information is displayed on standard out
+ */
+ public DescEntry[] getDescriptionFor(String job, String descPath,
+ boolean debug)
+ {
+
+ if (job.startsWith("-o"))
+ {
+ job = job.substring(3, job.length()).trim();
+
+ if (job.indexOf(".") < 0)
+ {
+ return null;
+ }
+
+ // special in case several Interfaces are given comma separated
+ if (job.indexOf(",") < 0)
+ {
+ DescEntry entry = getDescriptionForSingleJob(job, descPath,
+ debug);
+
+ if (entry != null)
+ {
+ return new DescEntry[]
+ {
+ entry
+ };
+ }
+ else
+ {
+ return null;
+ }
+ }
+ else
+ {
+ ArrayList subs = getSubInterfaces(job);
+ String partjob = job.substring(0, job.indexOf(",")).trim();
+ DescEntry entry = getDescriptionForSingleJob(partjob, descPath,
+ debug);
+
+ if (entry != null)
+ {
+ for (int i = 0; i < entry.SubEntryCount; i++)
+ {
+ String subEntry = entry.SubEntries[i].longName;
+ int cpLength = entry.longName.length();
+ subEntry = subEntry.substring(cpLength + 2,
+ subEntry.length());
+
+ if (subs.contains(subEntry))
+ {
+ entry.SubEntries[i].isToTest = true;
+ }
+ }
+
+ return new DescEntry[]
+ {
+ entry
+ };
+ }
+ else
+ {
+ return null;
+ }
+ }
+ }
+
+ if (job.startsWith("-p"))
+ {
+ job = job.substring(3, job.length()).trim();
+
+ String[] scenario = createScenario(descPath, job, debug);
+ if (scenario == null)
+ {
+ return null;
+ }
+ DescEntry[] entries = new DescEntry[scenario.length];
+ for (int i = 0; i < scenario.length; i++)
+ {
+ entries[i] = getDescriptionForSingleJob(
+ scenario[i].substring(3).trim(), descPath, debug);
+ }
+ if (job.equals("listall"))
+ {
+ util.dbg.printArray(scenario);
+ System.exit(0);
+ }
+ return entries;
+ }
+
+ if (job.startsWith("-sce"))
+ {
+ job = job.substring(5, job.length()).trim();
+
+ File sceFile = new File(job);
+ if (sceFile.exists())
+ {
+ return getScenario(job, descPath, debug);
+ }
+ else
+ {
+ //look the scenarion like this? :
+ // sw.SwXBodyText,sw.SwXTextCursor
+ ArrayList subs = getSubObjects(job);
+ DescEntry[] entries = new DescEntry[subs.size()];
+
+ for (int i = 0; i < subs.size(); i++)
+ {
+ entries[i] = getDescriptionForSingleJob(
+ (String) subs.get(i), descPath, debug);
+ }
+ return entries;
+ }
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ protected DescEntry getDescriptionForSingleJob(String job, String descPath,
+ boolean debug)
+ {
+ boolean isSingleInterface = job.indexOf("::") > 0;
+ fullJob = job;
+
+ if (isSingleInterface)
+ {
+ job = job.substring(0, job.indexOf("::"));
+ }
+
+ if (job.startsWith("bugs"))
+ {
+ DescEntry Entry = new DescEntry();
+ Entry.entryName = job;
+ Entry.longName = job;
+ Entry.EntryType = "bugdoc";
+ Entry.isOptional = false;
+ Entry.isToTest = true;
+ Entry.SubEntryCount = 0;
+ Entry.hasErrorMsg = false;
+ Entry.State = "non possible";
+
+ return Entry;
+ }
+
+ DescEntry entry = null;
+
+ if (descPath != null)
+ {
+ if (debug)
+ {
+ System.out.println("## reading from File " + descPath);
+ }
+
+ entry = getFromDirectory(descPath, job, debug);
+ }
+ else
+ {
+ if (debug)
+ {
+ System.out.println("## reading from jar");
+ }
+
+ entry = getFromClassPath(job, debug);
+ }
+
+ boolean foundInterface = false;
+
+ if (isSingleInterface && (entry != null))
+ {
+ for (int i = 0; i < entry.SubEntryCount; i++)
+ {
+ if (!(entry.SubEntries[i].longName).equals(fullJob))
+ {
+ entry.SubEntries[i].isToTest = false;
+ }
+ else
+ {
+ foundInterface = true;
+ entry.SubEntries[i].isToTest = true;
+ }
+ }
+ }
+
+ if (isSingleInterface && !foundInterface || entry == null)
+ {
+ return setErrorDescription(entry,
+ "couldn't find a description for test '" + fullJob + "'");
+ }
+
+ return entry;
+ }
+
+ protected static DescEntry[] getSubEntries(BufferedReader cvsFile,
+ DescEntry parent, boolean debug)
+ {
+ String line = "";
+ String old_ifc_name = "";
+ ArrayList ifc_names = new ArrayList();
+ ArrayList meth_names = new ArrayList();
+ DescEntry ifcDesc = null;
+
+ while (line != null)
+ {
+ try
+ {
+ line = cvsFile.readLine();
+ if (line == null)
+ {
+ continue;
+ }
+ if (line.startsWith("#"))
+ {
+ continue;
+ }
+ if (line.length() <= 0)
+ {
+ continue;
+ }
+// TODO Probleme here
+ // int nFirstSemicolon = line.indexOf(";");
+ // int nLastSemicolon = line.lastIndexOf(";");
+
+ String unknown;
+ String ifc_name = ""; // = line.substring(line.indexOf(";") + 2, line.lastIndexOf(";") - 1);
+ String meth_name = ""; // = line.substring(line.lastIndexOf(";") + 2, line.length() - 1);
+ StringTokenizer aToken = new StringTokenizer(line, ";");
+ if (aToken.countTokens() < 3)
+ {
+ System.out.println("Wrong format: Line '" + line + "' is not supported.");
+ continue;
+ }
+ if (aToken.hasMoreTokens())
+ {
+ unknown = StringHelper.removeQuoteIfExists(aToken.nextToken());
+ }
+ if (aToken.hasMoreTokens())
+ {
+ ifc_name = StringHelper.removeQuoteIfExists(aToken.nextToken());
+ }
+ if (aToken.hasMoreTokens())
+ {
+ meth_name = StringHelper.removeQuoteIfExists(aToken.nextToken());
+ }
+
+ // String ifc_name = line.substring(line.indexOf(";") + 2, line.lastIndexOf(";") - 1);
+ // String meth_name = line.substring(line.lastIndexOf(";") + 2, line.length() - 1);
+
+ DescEntry methDesc = createDescEntry(meth_name, ifc_name, parent);
+
+ if (!ifc_name.equals(old_ifc_name))
+ {
+ if (ifcDesc != null)
+ {
+ ifcDesc.SubEntries = getDescArray(meth_names.toArray());
+ ifcDesc.SubEntryCount = meth_names.size();
+
+ //mark service/interface as optional if all methods/properties are optional
+ boolean allOptional = true;
+
+ for (int k = 0; k < ifcDesc.SubEntryCount; k++)
+ {
+ if (!ifcDesc.SubEntries[k].isOptional)
+ {
+ allOptional = false;
+ }
+ }
+
+ if (!ifcDesc.isOptional && allOptional)
+ {
+ ifcDesc.isOptional = allOptional;
+ }
+
+ meth_names.clear();
+ ifc_names.add(ifcDesc);
+ }
+
+ ifcDesc = new DescEntry();
+ ifcDesc.isToTest = true;
+ old_ifc_name = ifc_name;
+
+ if (ifc_name.indexOf("#optional") > 0)
+ {
+ ifcDesc.isOptional = true;
+ ifc_name = ifc_name.substring(0, ifc_name.indexOf("#"));
+ }
+
+ String className = createClassName(ifc_name);
+
+ ifcDesc.EntryType = entryType;
+ ifcDesc.entryName = "ifc" + className;
+ ifcDesc.longName = parent.entryName + "::" + ifc_name;
+ }
+ meth_names.add(methDesc);
+
+ }
+ catch (java.io.IOException ioe)
+ {
+ parent.hasErrorMsg = true;
+ parent.ErrorMsg = "IOException while reading the description";
+
+ return null;
+ }
+ }
+
+ ifcDesc.SubEntries = getDescArray(meth_names.toArray());
+ ifcDesc.SubEntryCount = meth_names.size();
+
+ //mark service/interface as optional if all methods/properties are optional
+ boolean allOptional = true;
+
+ for (int k = 0; k < ifcDesc.SubEntryCount; k++)
+ {
+ if (!ifcDesc.SubEntries[k].isOptional)
+ {
+ allOptional = false;
+ }
+ }
+
+ if (!ifcDesc.isOptional && allOptional)
+ {
+ ifcDesc.isOptional = allOptional;
+ }
+
+ ifc_names.add(ifcDesc);
+
+ return getDescArray(makeArray(ifc_names));
+ }
+ private static String createClassName(String _ifc_name)
+ {
+ StringTokenizer st = new StringTokenizer(_ifc_name, ":");
+ String className = "";
+
+ int count = 3;
+
+ if (_ifc_name.startsWith("drafts"))
+ {
+ count = 4;
+ }
+
+ for (int i = 0; st.hasMoreTokens(); i++)
+ {
+ String token = st.nextToken();
+
+ // skipping (drafts.)com.sun.star
+ if (i >= count)
+ {
+ if (!st.hasMoreTokens())
+ {
+ // inserting '_' before the last token
+ token = "_" + token;
+ }
+
+ className += ("." + token);
+ }
+ }
+ return className;
+ }
+
+ private static String entryType;
+
+ private static DescEntry createDescEntry(String meth_name, String ifc_name, DescEntry parent)
+ {
+ entryType = "service";
+ DescEntry methDesc = new DescEntry();
+
+ if (meth_name.indexOf("#optional") > 0)
+ {
+ methDesc.isOptional = true;
+ meth_name = meth_name.substring(0, meth_name.indexOf("#"));
+ }
+
+ if (meth_name.endsWith("()"))
+ {
+ methDesc.EntryType = "method";
+ entryType = "interface";
+ }
+ else
+ {
+ methDesc.EntryType = "property";
+ entryType = "service";
+ }
+
+ methDesc.entryName = meth_name;
+ methDesc.isToTest = true;
+
+
+ String withoutHash = ifc_name;
+
+ if (ifc_name.indexOf("#optional") > 0)
+ {
+ withoutHash = ifc_name.substring(0, ifc_name.indexOf("#"));
+ }
+
+ methDesc.longName = parent.entryName + "::" + withoutHash + "::" + meth_name;
+
+ return methDesc;
+ }
+
+ private static void createIfcName(String ifc_name, ArrayList meth_names, DescEntry ifcDesc)
+ {
+ }
+
+ /**
+ * This method ensures that XComponent will be the last in the list of interfaces
+ */
+ protected static Object[] makeArray(ArrayList entries)
+ {
+ Object[] entriesArray = entries.toArray();
+ ArrayList returnArray = new ArrayList();
+ Object addAtEnd = null;
+
+ for (int k = 0; k < entriesArray.length; k++)
+ {
+ DescEntry entry = (DescEntry) entriesArray[k];
+
+ if (entry.entryName.equals("ifc.lang._XComponent"))
+ {
+ addAtEnd = entry;
+ }
+ else
+ {
+ returnArray.add(entry);
+ }
+ }
+
+ if (addAtEnd != null)
+ {
+ returnArray.add(addAtEnd);
+ }
+
+ return returnArray.toArray();
+ }
+
+ protected static DescEntry setErrorDescription(DescEntry entry,
+ String ErrorMsg)
+ {
+ if (entry == null)
+ {
+ entry = new DescEntry();
+ }
+ entry.hasErrorMsg = true;
+ entry.ErrorMsg = "Error while getting description for test '" +
+ fullJob + "' as an API test: " + ErrorMsg;
+
+ return entry;
+ }
+
+ protected static DescEntry[] getDescArray(Object[] list)
+ {
+ DescEntry[] entries = new DescEntry[list.length];
+
+ for (int i = 0; i < list.length; i++)
+ {
+ entries[i] = (DescEntry) list[i];
+ }
+
+ return entries;
+ }
+
+ protected DescEntry getFromClassPath(String aEntry, boolean debug)
+ {
+ int dotindex = aEntry.indexOf('.');
+
+ if (dotindex == -1)
+ {
+ return null;
+ }
+
+ String module = null;
+ String shortName = null;
+
+ if (aEntry.indexOf(".uno") == -1)
+ {
+ module = aEntry.substring(0, aEntry.indexOf('.'));
+ shortName = aEntry.substring(aEntry.indexOf('.') + 1);
+ }
+ else
+ {
+ module = aEntry.substring(0, aEntry.lastIndexOf('.'));
+ shortName = aEntry.substring(aEntry.lastIndexOf('.') + 1);
+ }
+
+ DescEntry theEntry = new DescEntry();
+ theEntry.entryName = aEntry;
+ theEntry.longName = aEntry;
+ theEntry.isOptional = false;
+ theEntry.EntryType = "component";
+ theEntry.isToTest = true;
+
+ BufferedReader csvFile = null;
+
+ java.net.URL url = this.getClass().getResource("/objdsc/" + module);
+
+ if (url == null)
+ {
+ return setErrorDescription(theEntry,
+ "couldn't find module '" + module + "'");
+ }
+
+ try
+ {
+ java.net.URLConnection con = url.openConnection();
+
+ String sEndsWithCSVName = "." + shortName.trim() + ".csv";
+ if (con instanceof java.net.JarURLConnection)
+ {
+ // get Jar file from connection
+ java.util.jar.JarFile f = ((java.net.JarURLConnection) con).getJarFile();
+
+ // Enumerate over all entries
+ java.util.Enumeration e = f.entries();
+
+ String sStartModule = "/" + module + "/";
+ while (e.hasMoreElements())
+ {
+
+ String entry = e.nextElement().toString();
+
+// if (debug) {
+// System.out.println("### Read from connetion: " + entry);
+// }
+
+ if ((entry.lastIndexOf(sStartModule) != -1) &&
+ entry.endsWith(sEndsWithCSVName))
+ {
+ InputStream input = this.getClass().getResourceAsStream("/" + entry);
+ csvFile = new BufferedReader(new InputStreamReader(input));
+ break;
+ }
+ }
+ }
+ else
+ {
+ InputStream in = con.getInputStream();
+ java.io.BufferedReader buf = new java.io.BufferedReader(new InputStreamReader(in));
+ boolean found = false;
+
+ while (buf.ready() && !found)
+ {
+ String entry = buf.readLine();
+
+ if (entry.endsWith(sEndsWithCSVName))
+ {
+ System.out.println("FOUND ####");
+ InputStream input = this.getClass().getResourceAsStream("/objdsc/" +
+ module +
+ "/" +
+ entry);
+ csvFile = new BufferedReader(
+ new InputStreamReader(input));
+ found = true;
+ }
+ }
+
+ buf.close();
+ }
+ }
+ catch (java.io.IOException e)
+ {
+ e.printStackTrace();
+ }
+
+ if (csvFile == null)
+ {
+ return setErrorDescription(theEntry,
+ "couldn't find component '" +
+ theEntry.entryName + "'");
+ }
+
+ DescEntry[] subEntries = getSubEntries(csvFile, theEntry, debug);
+
+ theEntry.SubEntryCount = subEntries.length;
+ theEntry.SubEntries = subEntries;
+
+ return theEntry;
+ }
+
+ protected static DescEntry getFromDirectory(String descPath, String entry,
+ boolean debug)
+ {
+ int dotindex = entry.indexOf('.');
+
+ if (dotindex == -1)
+ {
+ return null;
+ }
+
+ String fs = System.getProperty("file.separator");
+ String module = null;
+ String shortName = null;
+
+ if (entry.indexOf(".uno") == -1)
+ {
+ module = entry.substring(0, entry.indexOf('.'));
+ shortName = entry.substring(entry.indexOf('.') + 1);
+ }
+ else
+ {
+ module = entry.substring(0, entry.lastIndexOf('.'));
+ shortName = entry.substring(entry.lastIndexOf('.') + 1);
+ }
+
+ DescEntry aEntry = new DescEntry();
+ aEntry.entryName = entry;
+ aEntry.longName = entry;
+ aEntry.isOptional = false;
+ aEntry.EntryType = "component";
+ aEntry.isToTest = true;
+
+ if (debug)
+ {
+ System.out.println("Parsing Description Path: " + descPath);
+ System.out.println("Searching module: " + module);
+ System.out.println("For the Component " + shortName);
+ }
+
+ File modPath = new File(descPath + fs + module);
+
+ if (!modPath.exists())
+ {
+ return setErrorDescription(aEntry,
+ "couldn't find module '" + module + "'");
+ }
+
+ String[] files = modPath.list();
+ String found = "none";
+
+ for (int i = 0; i < files.length; i++)
+ {
+ if (files[i].endsWith("." + shortName + ".csv"))
+ {
+ found = files[i];
+ System.out.println("found " + found);
+ break;
+ }
+ }
+
+ if (found.equals("none"))
+ {
+ return setErrorDescription(aEntry,
+ "couldn't find component '" + entry + "'");
+ }
+
+ String aUrl = descPath + fs + module + fs + found;
+
+ BufferedReader csvFile = null;
+
+ try
+ {
+ csvFile = new BufferedReader(new FileReader(aUrl));
+ }
+ catch (java.io.FileNotFoundException fnfe)
+ {
+ return setErrorDescription(aEntry, "couldn't find file '" + aUrl + "'");
+ }
+
+ DescEntry[] subEntries = getSubEntries(csvFile, aEntry, debug);
+
+ aEntry.SubEntryCount = subEntries.length;
+ aEntry.SubEntries = subEntries;
+
+ return aEntry;
+ }
+
+ protected ArrayList getSubInterfaces(String job)
+ {
+ ArrayList namesList = new ArrayList();
+ StringTokenizer st = new StringTokenizer(job, ",");
+
+ for (int i = 0; st.hasMoreTokens(); i++)
+ {
+ String token = st.nextToken();
+
+ if (token.indexOf(".") < 0)
+ {
+ namesList.add(token);
+ }
+ }
+
+ return namesList;
+ }
+
+ protected ArrayList getSubObjects(String job)
+ {
+ ArrayList namesList = new ArrayList();
+ StringTokenizer st = new StringTokenizer(job, ",");
+
+ for (int i = 0; st.hasMoreTokens(); i++)
+ {
+ namesList.add(st.nextToken());
+ }
+
+ return namesList;
+ }
+
+ protected String[] createScenario(String descPath, String job,
+ boolean debug)
+ {
+ String[] scenario = null;
+
+ if (descPath != null)
+ {
+ if (debug)
+ {
+ System.out.println("## reading from File " + descPath);
+ }
+
+ scenario = getScenarioFromDirectory(descPath, job, debug);
+ }
+ else
+ {
+ if (debug)
+ {
+ System.out.println("## reading from jar");
+ }
+
+ scenario = getScenarioFromClassPath(job, debug);
+ }
+
+ return scenario;
+ }
+
+ protected String[] getScenarioFromDirectory(String descPath, String job,
+ boolean debug)
+ {
+ String[] modules = null;
+ ArrayList componentList = new ArrayList();
+
+ if (!job.equals("unknown") && !job.equals("listall"))
+ {
+ modules = new String[]
+ {
+ job
+ };
+ }
+ else
+ {
+ File dirs = new File(descPath);
+
+ if (!dirs.exists())
+ {
+ modules = null;
+ }
+ else
+ {
+ modules = dirs.list();
+ }
+ }
+
+ for (int i = 0; i < modules.length; i++)
+ {
+ if (!isUnusedModule(modules[i]))
+ {
+ File moduleDir = new File(descPath + System.getProperty("file.separator") + modules[i]);
+ if (moduleDir.exists())
+ {
+ String[] components = moduleDir.list();
+ for (int j = 0; j < components.length; j++)
+ {
+ if (components[j].endsWith(".csv"))
+ {
+ String toAdd = getComponentForString(components[j], modules[i]);
+ toAdd = "-o " + modules[i] + "." + toAdd;
+ componentList.add(toAdd);
+ }
+ }
+ }
+ }
+ }
+
+ String[] scenario = new String[componentList.size()];
+ Collections.sort(componentList);
+
+ for (int i = 0; i < componentList.size(); i++)
+ {
+ scenario[i] = (String) componentList.get(i);
+ }
+
+ return scenario;
+
+ }
+
+ protected String[] getScenarioFromClassPath(String job, boolean debug)
+ {
+ String subdir = "/";
+
+ if (!job.equals("unknown") && !job.equals("listall"))
+ {
+ subdir += job;
+ }
+
+ java.net.URL url = this.getClass().getResource("/objdsc" + subdir);
+
+ if (url == null)
+ {
+ return null;
+ }
+
+ ArrayList scenarioList = new ArrayList();
+
+ try
+ {
+ java.net.URLConnection con = url.openConnection();
+
+ if (con instanceof java.net.JarURLConnection)
+ {
+ // get Jar file from connection
+ java.util.jar.JarFile f = ((java.net.JarURLConnection) con).getJarFile();
+
+ // Enumerate over all entries
+ java.util.Enumeration e = f.entries();
+
+ while (e.hasMoreElements())
+ {
+ String entry = e.nextElement().toString();
+
+ if (entry.startsWith("objdsc" + subdir) &&
+ (entry.indexOf("CVS") < 0) &&
+ !entry.endsWith("/"))
+ {
+ int startMod = entry.indexOf("/");
+ int endMod = entry.lastIndexOf("/");
+ String module = entry.substring(startMod + 1, endMod);
+ String component = getComponentForString(
+ entry.substring(endMod + 1,
+ entry.length()),
+ module);
+
+ if (!isUnusedModule(module))
+ {
+ scenarioList.add("-o " + module + "." +
+ component);
+ }
+ }
+ }
+ }
+ }
+ catch (java.io.IOException e)
+ {
+ e.printStackTrace();
+ }
+
+ String[] scenario = new String[scenarioList.size()];
+ Collections.sort(scenarioList);
+
+ for (int i = 0; i < scenarioList.size(); i++)
+ {
+ scenario[i] = (String) scenarioList.get(i);
+ }
+
+ return scenario;
+ }
+
+ protected String getComponentForString(String full, String module)
+ {
+ String component = "";
+
+
+ //cutting .csv
+ full = full.substring(0, full.length() - 4);
+
+ //cutting component
+ int lastdot = full.lastIndexOf(".");
+ component = full.substring(lastdot + 1, full.length());
+
+ if (module.equals("file") || module.equals("xmloff"))
+ {
+ String withoutComponent = full.substring(0, lastdot);
+ int preLastDot = withoutComponent.lastIndexOf(".");
+ component = withoutComponent.substring(preLastDot + 1,
+ withoutComponent.length()) +
+ "." + component;
+ }
+
+ return component;
+ }
+
+ protected boolean isUnusedModule(String moduleName)
+ {
+ ArrayList removed = new ArrayList();
+ removed.add("acceptor");
+ removed.add("brdgfctr");
+ removed.add("connectr");
+ removed.add("corefl");
+ removed.add("cpld");
+ removed.add("defreg");
+ removed.add("dynamicloader");
+ removed.add("impreg");
+ removed.add("insp");
+ removed.add("inv");
+ removed.add("invadp");
+ removed.add("javaloader");
+ removed.add("jen");
+ removed.add("namingservice");
+ removed.add("proxyfac");
+ removed.add("rdbtdp");
+ removed.add("remotebridge");
+ removed.add("simreg");
+ removed.add("smgr");
+ removed.add("stm");
+ removed.add("tcv");
+ removed.add("tdmgr");
+ removed.add("ucprmt");
+ removed.add("uuresolver");
+
+ return removed.contains(moduleName);
+ }
+}
diff --git a/qadevOOo/runner/helper/AppProvider.java b/qadevOOo/runner/helper/AppProvider.java
new file mode 100644
index 000000000000..f8cf7e9737db
--- /dev/null
+++ b/qadevOOo/runner/helper/AppProvider.java
@@ -0,0 +1,55 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package helper;
+
+/**
+ *
+ * Interface to get a Manager to access the application to check
+ */
+public interface AppProvider {
+
+ /**
+ * Method to get the desired Manager
+ */
+ public Object getManager(lib.TestParameters param);
+
+ /**
+ * Method to dispose the desired Manager
+ */
+ public boolean disposeManager(lib.TestParameters param);
+
+ /**
+ * Close an office.
+ * @param param The test parameters.
+ * @param closeIfPossible If true, close even if
+ * it was running before the test
+ * @return True, if close worked.
+ */
+ public boolean closeExistingOffice(lib.TestParameters param,
+ boolean closeIfPossible);
+}
diff --git a/qadevOOo/runner/helper/BuildEnvTools.java b/qadevOOo/runner/helper/BuildEnvTools.java
new file mode 100644
index 000000000000..296b56877717
--- /dev/null
+++ b/qadevOOo/runner/helper/BuildEnvTools.java
@@ -0,0 +1,195 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package helper;
+
+import java.io.File;
+import java.io.PrintWriter;
+import lib.TestParameters;
+import share.LogWriter;
+import util.*;
+
+/**
+ * This class support you to execute some shell commands in a buld environment. At ervery call of commands
+ * a build environment was created and the commands will be executed.
+ *
+ */
+public class BuildEnvTools {
+
+ private final TestParameters param;
+ private final LogWriter log;
+ private final boolean mDebug;
+ private final String mPlatform;
+ private final String mShell;
+ private boolean mCygwin;
+
+ /**
+ * This constructor creates an instance of BuildEncTools. It is verifying for all neccesarry
+ * parameters in <CODE>TestParameters</CODE> This must be:
+ * <ul>
+ * <li>OperatingSystem: Fill this parameter with an operating system like unxsols, unxsoli, unxlngi or wntmsci.
+ * </li>
+ * <li> Shell: Fill this parameter with a shell f.e '/bin/tcsh'
+ * or 'c:\\myShell\\myShell.exe'
+ * </li>
+ * @param param
+ * @param log
+ * @throws helper.ParameterNotFoundException
+ */
+ public BuildEnvTools(TestParameters param, LogWriter log) throws ParameterNotFoundException {
+ this.param = param;
+ this.log = log;
+ mDebug = param.getBool(PropertyName.DEBUG_IS_ACTIVE);
+
+ boolean error = false;
+
+ String msg = "\nERROR: the following parameter must be set before executing the test:\n\n";
+
+ mPlatform = (String) param.get(PropertyName.OPERATING_SYSTEM);
+ if (mDebug) {
+ log.println("### " + mPlatform);
+ }
+ if (mPlatform == null){
+ msg += PropertyName.OPERATING_SYSTEM + "\nFill this parameter with an operating system like unxsols," +
+ " unxsoli, unxlngi, unxmacxi or wntmsci. \n\n";
+ }
+ if(
+ (!mPlatform.equalsIgnoreCase(PropertyName.UNXSOLS)) &&
+ (!mPlatform.equalsIgnoreCase(PropertyName.UNXSOLI)) &&
+ (!mPlatform.equalsIgnoreCase(PropertyName.UNXLNGI)) &&
+ (!mPlatform.equalsIgnoreCase(PropertyName.UNXMACXI))&&
+ (!mPlatform.equalsIgnoreCase(PropertyName.WNTMSCI)) ){
+
+ msg += PropertyName.OPERATING_SYSTEM + ":" + mPlatform + "\nFill this parameter with an operating system like unxsols," +
+ " unxsoli, unxlngi, unxmacxi or wntmsci. \n\n";
+ error = true;
+ }
+
+ mShell = (String) param.get(PropertyName.SHELL);
+ if (mShell == null) {
+ msg += PropertyName.SHELL + "\nFill this parameter with a shell" +
+ "\n\t/bin/tcsh c:\\myShell\\myShell.exe\n\n";
+ error = true;
+ }
+
+ mCygwin = (param.getBool(PropertyName.CYGWIN));
+
+ if (error) {
+ throw new ParameterNotFoundException(msg);
+ }
+ }
+
+ /**
+ * Executes the given commands in OOo-Environment shell.
+ * @param commands
+ * @param workDir
+ * @param shortWait
+ * @return the processHandler of the commands
+ * @see helper.ProcessHandler
+ */
+ public ProcessHandler runCommandsInEnvironmentShell(String[] commands, File workDir, int shortWait) {
+
+ final String[] cmdLines = getCmdLinesWithCommand(commands);
+ final ProcessHandler pHdl = new ProcessHandler(cmdLines, (PrintWriter) log, workDir, shortWait, param);
+ pHdl.runCommand();
+ return pHdl;
+ }
+
+ public String getSrcRoot() {
+
+ String sSrcRoot = (String) param.get(PropertyName.SRC_ROOT);
+
+ if (sSrcRoot == null) {
+ String[] cmdLines = null;
+ if (mPlatform.equals(PropertyName.WNTMSCI) && ! mCygwin) {
+ cmdLines = new String[]{mShell, "/C", "echo SRC_ROOT=%SRC_ROOT"};
+ } else {
+ cmdLines = new String[]{mShell, "--login ", "-c ", "echo \"SRC_ROOT=$SRC_ROOT\""};
+ }
+
+ final ProcessHandler procHdl = new ProcessHandler(cmdLines, (PrintWriter) log, null, 5000, param);
+ procHdl.runCommand();
+
+ if (mDebug) {
+ log.println("---> Output of command:");
+ log.println(procHdl.getOutputText());
+ log.println("<--- Output of command:");
+ log.println("---> Error output of command");
+ log.println(procHdl.getErrorText());
+ log.println("<--- Error output of command");
+ }
+ final String output = procHdl.getOutputText();
+ final String[] outs = output.split("\n");
+
+ for (int i = 0; i < outs.length; i++) {
+ final String line = outs[i];
+ if (line.startsWith("SRC_ROOT")) {
+ sSrcRoot = getEnvValue(line);
+ }
+ }
+ }
+ return sSrcRoot;
+ }
+
+ private String[] getCmdLinesWithCommand(String[] commands) {
+ String[] cmdLines = null;
+ log.println("prepare command for platform " + mPlatform);
+
+ String seperator = "";
+ if (mPlatform.equals(PropertyName.WNTMSCI)) {
+ seperator = mCygwin ? ";" : "^";
+ } else {
+ seperator = ";";
+ }
+
+ String command = "";
+ for (int i = 0; i < commands.length; i++) {
+ if (i != 0) {
+ command += seperator;
+ }
+ command += commands[i];
+ }
+
+ if (mPlatform.equals(PropertyName.WNTMSCI)){
+ if (mCygwin){
+ String srcRoot = (String) param.get(PropertyName.SRC_ROOT);
+ String envSet = "export cyg_src_root=`cygpath '" + srcRoot.replaceAll("\\\\", "\\\\\\\\")+ "'`; source $cyg_src_root/winenv.set.sh;";
+ command = envSet + command;
+ cmdLines = new String[]{mShell, "--login", "-c", "\"" + command + "\""};
+ } else {
+ cmdLines = new String[]{mShell, "/C", "\"" + command + "\""};
+ }
+ } else {
+ cmdLines = new String[]{mShell, "-c", command};
+ }
+ return cmdLines;
+ }
+
+ private String getEnvValue(String line) {
+ final String[] split = line.split("=");
+ return split[1];
+ }
+}
diff --git a/qadevOOo/runner/helper/CfgParser.java b/qadevOOo/runner/helper/CfgParser.java
new file mode 100644
index 000000000000..f4f919c5cfc4
--- /dev/null
+++ b/qadevOOo/runner/helper/CfgParser.java
@@ -0,0 +1,192 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package helper;
+
+import lib.TestParameters;
+import java.util.Properties;
+import java.util.Enumeration;
+import java.io.FileInputStream;
+import util.PropertyName;
+
+/**
+ * This class parses the ini files and stores the data
+ * <br>
+ * inside TestParameters
+ */
+public class CfgParser
+{
+
+ protected boolean debug = false;
+ protected String iniFile = "";
+
+ public CfgParser(String ini)
+ {
+ if (ini != null)
+ {
+ this.iniFile = ini;
+ }
+ }
+
+ public void getIniParameters(TestParameters param)
+ {
+ debug = param.DebugIsActive;
+ Properties cfg = null;
+ 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)
+ {
+ cfg = getProperties(getDefaultFileName(false));
+ }
+ }
+ else
+ {
+ cfg = getProperties(iniFile);
+ }
+
+ if (cfg != null)
+ {
+ Enumeration cfgEnum = cfg.keys();
+ while (cfgEnum.hasMoreElements())
+ {
+ String pName = (String) cfgEnum.nextElement();
+ Object pValue = cfg.getProperty(pName);
+
+ if (pValue instanceof String)
+ {
+ pValue = ((String) pValue).trim();
+ }
+
+ param.put(pName.trim(), pValue);
+
+ if (pName.equals(PropertyName.TEST_DOCUMENT_PATH))
+ {
+
+ param.put("DOCPTH", (String) pValue);
+ System.setProperty("DOCPTH", (String) pValue);
+
+ }
+ else if (pName.equals(PropertyName.SRC_ROOT))
+ {
+
+ System.setProperty(pName, (String) pValue);
+
+ }
+ }
+ }
+
+ debug = param.DebugIsActive;
+
+ //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)
+ {
+
+ //found something that could be a prefex
+ //check all parameters for this
+ Enumeration keys = param.keys();
+ while (keys.hasMoreElements())
+ {
+ String key = (String) keys.nextElement();
+ if (key.startsWith(os))
+ {
+ Object oldValue = param.get(key);
+ String newKey = key.substring(os.length() + 1);
+ param.remove(key);
+ param.put(newKey, oldValue);
+ }
+ }
+
+ }
+ }
+
+ protected Properties getProperties(String name)
+ {
+ // get the resource file
+ Properties prop = new Properties();
+ if (debug)
+ {
+ System.out.println("Looking for " + name);
+ }
+ try
+ {
+ FileInputStream propFile = new FileInputStream(name);
+ prop.load(propFile);
+ 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);
+ java.net.URLConnection connection = url.openConnection();
+ java.io.InputStream in = connection.getInputStream();
+ prop.load(in);
+ }
+ }
+ catch (Exception ex)
+ {
+ //Exception while reading prop-file, returning null
+ return null;
+ }
+ }
+
+ return prop;
+ }
+
+ protected String getDefaultFileName(boolean home)
+ {
+ String fileSeparator = System.getProperty("file.separator");
+ String path = "";
+ if (home)
+ {
+ //look inside the home directory
+ path = System.getProperty("user.home");
+ }
+ else
+ {
+ path = System.getProperty("user.dir");
+ }
+ if (fileSeparator.equals("/"))
+ {
+ //suppose I'm on Unix-platform
+ return path + fileSeparator + ".runner.props";
+ }
+ else
+ {
+ //suppose I'm on Windows
+ return path + fileSeparator + "runner.props";
+ }
+ }
+}
diff --git a/qadevOOo/runner/helper/ClParser.java b/qadevOOo/runner/helper/ClParser.java
new file mode 100644
index 000000000000..583aea56f977
--- /dev/null
+++ b/qadevOOo/runner/helper/ClParser.java
@@ -0,0 +1,193 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package helper;
+
+import java.io.File;
+import java.util.Properties;
+
+import lib.TestParameters;
+import util.PropertyName;
+import util.utils;
+
+/**
+ * This class parses commandline Argument and stores <br>
+ * them into TestParameter
+ */
+public class ClParser
+{
+ /*
+ * Parses the commandline argument and puts them<br>
+ * into the TestParameters
+ */
+
+ public void getCommandLineParameter(TestParameters param, String[] args)
+ {
+ Properties mapping = getMapping();
+
+ 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))
+ {
+ pValue = args[i].trim() + " " + args[i + 1].trim();
+ i += 2;
+ }
+ else
+ {
+ pValue = args[i].trim() + " unknown";
+ i += 2;
+ }
+ }
+ else
+ {
+ if ((i + 1) < args.length)
+ {
+ pValue = args[i + 1].trim();
+
+ if (pValue.startsWith("-"))
+ {
+ i++;
+ pValue = "yes";
+ }
+ else if (pValue.startsWith("'"))
+ {
+ i++;
+ while (!pValue.endsWith("'"))
+ {
+ i++;
+ pValue = pValue + " " + args[i].trim();
+
+ }
+ pValue = utils.replaceAll13(pValue, "'", "");
+ i++;
+ }
+ else
+ {
+ i += 2;
+ }
+
+ if (pName.equals("TestDocumentPath"))
+ {
+ System.setProperty(
+ "DOCPTH", new File(pValue).getAbsolutePath());
+ }
+ else if (pName.equals(PropertyName.SRC_ROOT))
+ {
+ System.setProperty(pName, pValue);
+
+ }
+ }
+ else
+ {
+ pValue = "yes";
+ i++;
+ }
+ }
+
+ param.put(pName, pValue);
+ }
+ }
+
+ /*
+ * 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)
+ {
+ String iniFile = "";
+
+ for (int i = 0; i < args.length; i++)
+ {
+ if (args[i].equals("-ini"))
+ {
+ iniFile = args[i + 1];
+ break;
+ }
+ }
+
+ return iniFile;
+ }
+
+ /*
+ * 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)
+ {
+ String iniFile = "";
+
+ for (int i = 0; i < args.length; i++)
+ {
+ if (args[i].equals("-runnerini"))
+ {
+ iniFile = args[i + 1];
+ break;
+ }
+ }
+
+ return iniFile;
+ }
+
+ /*
+ * This method maps commandline Parameters to TestParameters
+ */
+ protected Properties getMapping()
+ {
+ Properties map = new Properties();
+ map.setProperty("-cs", "ConnectionString");
+ map.setProperty("-tb", "TestBase");
+ map.setProperty("-tdoc", "TestDocumentPath");
+ map.setProperty("-objdsc", "DescriptionPath");
+ map.setProperty("-cmd", "AppExecutionCommand");
+ map.setProperty("-o", "TestJob");
+ map.setProperty("-sce", "TestJob");
+ map.setProperty("-p", "TestJob");
+ map.setProperty("-aca", "AdditionalConnectionArguments");
+ map.setProperty("-xcl", "ExclusionList");
+ map.setProperty("-debug", "DebugIsActive");
+ map.setProperty("-log", "LoggingIsActive");
+ map.setProperty("-dbout", "DataBaseOut");
+ map.setProperty("-nca", "NoCwsAttach");
+
+ return map;
+ }
+
+ protected String getParameterFor(Properties map, String name)
+ {
+ String ret = map.getProperty(name);
+
+ if (ret == null)
+ {
+ ret = name.substring(1);
+ }
+
+ return ret;
+ }
+} \ No newline at end of file
diff --git a/qadevOOo/runner/helper/ComplexDescGetter.java b/qadevOOo/runner/helper/ComplexDescGetter.java
new file mode 100644
index 000000000000..287c0402fb77
--- /dev/null
+++ b/qadevOOo/runner/helper/ComplexDescGetter.java
@@ -0,0 +1,194 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package helper;
+
+import complexlib.ComplexTestCase;
+import util.DynamicClassLoader;
+import share.DescEntry;
+import share.DescGetter;
+import share.ComplexTest;
+import java.util.Vector;
+import share.LogWriter;
+
+/**
+ *
+ */
+public class ComplexDescGetter extends DescGetter
+{
+
+ ComplexTest testClass;
+
+ /** Creates new ComplexDescGetter */
+ public ComplexDescGetter()
+ {
+ testClass = null;
+ }
+
+ public DescEntry[] getDescriptionFor(String entry, String DescPath,
+ boolean debug)
+ {
+ // read scenario file
+ if (entry.startsWith("-sce"))
+ {
+ DescEntry[] entries = getScenario(entry.substring(5), null, debug);
+ return entries;
+ }
+ // one single job
+ else if (entry.startsWith("-o"))
+ {
+ DescEntry dEntry = getDescriptionForSingleJob(entry.substring(3), null, debug);
+ if (dEntry != null)
+ {
+ return new DescEntry[]
+ {
+ dEntry
+ };
+ }
+ }
+ 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)
+ {
+ DynamicClassLoader dcl = new DynamicClassLoader();
+ String methodNames[] = null;
+
+ if (debug)
+ {
+ System.out.println("Searching Class: " + className);
+ }
+
+ int index = className.indexOf("::");
+ if (index != -1)
+ {
+ // case1: method()
+ // case2: method(param1,param2)
+ // case3: method1(param1,param2),method2(param1,param2)
+ String method = className.substring(index + 2);
+ className = className.substring(0, index);
+ Vector methods = new Vector();
+
+ String[] split = method.split("(?<=\\)),(?=\\w+)");
+
+ for (int i = 0; i < split.length; i++)
+ {
+ String meth = split[i];
+
+ if (meth.endsWith("()"))
+ {
+ meth = meth.substring(0, meth.length() - 2);
+ }
+
+ methods.add(meth);
+ }
+
+ methodNames = new String[methods.size()];
+ methodNames = (String[]) methods.toArray(methodNames);
+ }
+
+ // create an instance
+ 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.");
+ return null;
+ }
+ 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());
+ }
+
+ String testObjectName = className;
+ String[] testMethodNames = null;
+
+ if (testMethodNames == null)
+ {
+ testMethodNames = testClass.getTestMethodNames();
+ }
+ if (methodNames != null)
+ {
+ testMethodNames = methodNames;
+ }
+
+ DescEntry dEntry = createTestDesc(testObjectName, className, testMethodNames, null);
+
+ return dEntry;
+ }
+
+ /**
+ * Creates a description exntry for the given parameter
+ * @param testObjectName the name of the object
+ * @param className the class name of the class to load
+ * @param testMethodNames list of all methods to test
+ * @param log
+ * @return filled description entry
+ */
+ public DescEntry createTestDesc(String testObjectName, String className, String[] testMethodNames, LogWriter log)
+ {
+
+ DescEntry dEntry = new DescEntry();
+
+ dEntry.entryName = testObjectName;
+ dEntry.longName = className;
+ dEntry.isOptional = false;
+ dEntry.EntryType = "unit";
+ dEntry.isToTest = true;
+ dEntry.Logger = log;
+ dEntry.SubEntryCount = testMethodNames.length;
+ dEntry.SubEntries = new DescEntry[dEntry.SubEntryCount];
+ for (int i = 0; i < dEntry.SubEntryCount; i++)
+ {
+ DescEntry aEntry = new DescEntry();
+ aEntry.entryName = testMethodNames[i];
+ aEntry.longName = testObjectName + "::" + aEntry.entryName;
+ aEntry.isOptional = false;
+ aEntry.EntryType = "method";
+ aEntry.isToTest = true;
+ dEntry.SubEntries[i] = aEntry;
+ dEntry.Logger = log;
+ }
+
+ return dEntry;
+ }
+
+ protected String[] createScenario(String descPath, String job, boolean debug)
+ {
+ return new String[] {};
+ }
+}
diff --git a/qadevOOo/runner/helper/ConfigHelper.java b/qadevOOo/runner/helper/ConfigHelper.java
new file mode 100644
index 000000000000..088b927376f6
--- /dev/null
+++ b/qadevOOo/runner/helper/ConfigHelper.java
@@ -0,0 +1,348 @@
+package helper;
+
+import com.sun.star.uno.*;
+import com.sun.star.lang.*;
+import com.sun.star.container.*;
+import com.sun.star.beans.*;
+import com.sun.star.util.*;
+
+/**
+ * This <CODE>ConfigHelper</CODE> makes it possible to access the
+ * configuration and change their content.<P>
+ * <P>
+ * Example: <P>
+ * Listing of the <CODE>Configuration</CODE> Views.xcu:<P>
+ * &lt;oor:component-data xmlns:oor=&quot;http://openoffice.org/2001/registry&quot; xmlns:xs=&quot;http://www.w3.org/2001/XMLSchema&quot; oor:name=&quot;Views&quot; oor:package=&quot;org.openoffice.Office&quot;&gt;<p>
+ * &lt;node oor:name=&quot;Windows&quot;&gt;<P>
+ * <&lt;node oor:name=&quot;SplitWindow0&quot; oor:op=&quot;replace&quot;&gt;<P>
+ * &lt;prop oor:name=&quot;Visible&quot; oor:type=&quot;xs:boolean&quot;&gt;<P>
+ * &lt;value&gt;false&lt;/value&gt;<P>
+ * &lt;/prop&gt;<P>
+ * &lt;prop oor:name=&quot;WindowState&quot; oor:type=&quot;xs:string&quot;&gt;<P>
+ * &lt;value/&gt;<P>
+ * &lt;/prop&gt;<P>
+ * &lt;node oor:name=&quot;UserData&quot;&gt;<P>
+ * &lt;prop oor:name=&quot;UserItem&quot; oor:op=&quot;replace&quot;
+ * oor:type=&quot;xs:string&quot;&gt;<P>
+ * &lt;value&gt;V1,2,0&lt;/value&gt;<P>
+ * &lt;/prop&gt;<P>
+ * &lt;/node&gt;<P>
+ * &lt;/node&gt;<P>
+ * &lt;/node&gt;<P>
+ * <P>
+ * <CODE>Definition</CODE><P>
+ * <ul>
+ * <li><CODE>&lt;node oor:name=&quot;Windows&quot;&gt;</CODE>
+ * represents a <CODE>Set</CODE> and is a <CODE>XNameContainer</CODE></LI>
+ * <li><CODE>&lt;node oor:name=&quot;SplitWindow0&quot;&gt;</CODE>
+ * represents a <CODE>Group</CODE> and is a <CODE>XNameReplace</CODE></LI>
+ * <li><CODE>&lt;prop oor:name=&quot;Visible&quot;&gt;</CODE>
+ * represents a pr<CODE></CODE>operty of the group</li>
+ * <li><CODE>&lt;node oor:name=&quot;UserData&quot;&gt;</CODE>
+ * represents a <CODE>extensible group</CODE> and is a <CODE>XNameContainer</CODE></LI>
+ * <li><CODE>&lt;prop oor:name=&quot;UserItem&quot;&gt;</CODE>
+ * represents a <CODE>property</CODE> of the extensible group</LI>
+ * </UL>
+ * We assume in the following examples the existance of:<P>
+ * <CODE>ConfigHelper aConfig = new ConfigHelper(xMSF, "org.openoffice.Office.Views", false);</CODE>
+ * <ul>
+ * <li>If you like to insert a new <CODE>Group</CODE> into the <CODE>Set</CODE> "Windows":<p>
+ * <CODE>XNameReplace xMyGroup = aConfig.getOrInsertGroup("Windows", "myGroup");</CODE><P>
+ * The method <CODE>getOrInsertGroup()</CODE> uses the
+ * <CODE>XSingleServiceFactory</CODE> to create the skeleton of a new group.
+ *
+ * </li>
+ * <li>If you like to change the property "WindowState" of "myGroup"
+ * of the Set "Windows"<p>
+ * <CODE>aConfig.updateGroupProperty(
+ * "Windows","myGroup", "WindowState", "952,180,244,349;1;0,0,0,0;");</CODE>
+ * </li>
+ * <li>If you like to change the property "myProp" of the extensible group
+ * "myExtGroup" which is an extensible group of "my2ndGroup" of the
+ * Set "Windows":<p>
+ * <CODE>aConfig.insertOrUpdateExtensibleGroupProperty(
+ * "Windows", "my2ndGroup", "myExtGroup", "myProp","TheValue");</CODE>
+ * </li>
+ * </ul>
+ */
+public class ConfigHelper
+{
+ private XMultiServiceFactory m_xSMGR = null;
+ private XHierarchicalNameAccess m_xConfig = null;
+
+ //-----------------------------------------------
+ public ConfigHelper(XMultiServiceFactory xSMGR ,
+ String sConfigPath ,
+ boolean bReadOnly )
+ throws com.sun.star.uno.Exception
+ {
+ m_xSMGR = xSMGR;
+
+ XMultiServiceFactory xConfigRoot = (XMultiServiceFactory)
+ UnoRuntime.queryInterface(
+ XMultiServiceFactory.class,
+ m_xSMGR.createInstance(
+ "com.sun.star.configuration.ConfigurationProvider"));
+
+ PropertyValue[] lParams = new PropertyValue[1];
+ lParams[0] = new PropertyValue();
+ lParams[0].Name = "nodepath";
+ lParams[0].Value = sConfigPath;
+
+ Object aConfig;
+ if (bReadOnly)
+ aConfig = xConfigRoot.createInstanceWithArguments(
+ "com.sun.star.configuration.ConfigurationAccess",
+ lParams);
+ else
+ aConfig = xConfigRoot.createInstanceWithArguments(
+ "com.sun.star.configuration.ConfigurationUpdateAccess",
+ lParams);
+
+ m_xConfig = (XHierarchicalNameAccess)UnoRuntime.queryInterface(
+ XHierarchicalNameAccess.class,
+ aConfig);
+
+ if (m_xConfig == null)
+ throw new com.sun.star.uno.Exception("Could not open configuration \""+sConfigPath+"\"");
+ }
+
+ //-----------------------------------------------
+ public Object readRelativeKey(String sRelPath,
+ String sKey )
+ throws com.sun.star.container.NoSuchElementException
+ {
+ try
+ {
+ XPropertySet xPath = (XPropertySet)UnoRuntime.queryInterface(
+ XPropertySet.class,
+ m_xConfig.getByHierarchicalName(sRelPath));
+ return xPath.getPropertyValue(sKey);
+ }
+ catch(com.sun.star.uno.Exception ex)
+ {
+ throw new com.sun.star.container.NoSuchElementException(ex.getMessage());
+ }
+ }
+
+ //-----------------------------------------------
+ public void writeRelativeKey(String sRelPath,
+ String sKey ,
+ Object aValue )
+ throws com.sun.star.container.NoSuchElementException
+ {
+ try
+ {
+ XPropertySet xPath = (XPropertySet)UnoRuntime.queryInterface(
+ XPropertySet.class,
+ m_xConfig.getByHierarchicalName(sRelPath));
+ xPath.setPropertyValue(sKey, aValue);
+ }
+ catch(com.sun.star.uno.Exception ex)
+ {
+ throw new com.sun.star.container.NoSuchElementException(ex.getMessage());
+ }
+ }
+
+ //-----------------------------------------------
+ /**
+ * Updates the configuration.<p>
+ * This must be called after you have changed the configuration
+ * else you changes will be lost.
+ */
+ public void flush()
+ {
+ try
+ {
+ XChangesBatch xBatch = (XChangesBatch)UnoRuntime.queryInterface(
+ XChangesBatch.class,
+ m_xConfig);
+ xBatch.commitChanges();
+ }
+ catch(com.sun.star.uno.Exception ex)
+ {}
+ }
+
+ //-----------------------------------------------
+ public static Object readDirectKey(XMultiServiceFactory xSMGR ,
+ String sConfigFile,
+ String sRelPath ,
+ String sKey )
+ throws com.sun.star.uno.Exception
+ {
+ ConfigHelper aConfig = new ConfigHelper(xSMGR, sConfigFile, true);
+ return aConfig.readRelativeKey(sRelPath, sKey);
+ }
+
+ //-----------------------------------------------
+ public static void writeDirectKey(XMultiServiceFactory xSMGR ,
+ String sConfigFile,
+ String sRelPath ,
+ String sKey ,
+ Object aValue )
+ throws com.sun.star.uno.Exception
+ {
+ ConfigHelper aConfig = new ConfigHelper(xSMGR, sConfigFile, false);
+ aConfig.writeRelativeKey(sRelPath, sKey, aValue);
+ aConfig.flush();
+ }
+
+
+ /**
+ * Insert a structured node (group) in a name container (set)
+ * or else update it and retrun the <CODE>XNameReplace</CODE> of it.<P>
+ * The <CODE>XSingleServiceFacttory</CODE> of the <CODE>set</CODE> will be used
+ * to create a new group. This group is specific to its set and
+ * creates defined entries.
+ * @return The [inserted] group of the set
+ * @param groupName The name of the goup which should be returned
+ * @param setName The name of the set
+ * @throws com.sun.star.uno.Exception throws
+ * <CODE>com.sun.star.uno.Exeception</CODE> on any error.
+ */
+ public XNameReplace getOrInsertGroup(String setName, String groupName)
+ throws com.sun.star.uno.Exception
+
+ {
+ XNameContainer xSetCont = this.getSet(setName);
+
+ XNameReplace xChildAccess = null;
+
+ try {
+ Object xChild=xSetCont.getByName(groupName);
+ xChildAccess = (XNameReplace) UnoRuntime.queryInterface(
+ XNameReplace.class,xSetCont);
+ } catch(com.sun.star.container.NoSuchElementException e) {
+ // proceed with inserting
+ }
+
+ if (xChildAccess == null) {
+ XSingleServiceFactory xChildfactory = (XSingleServiceFactory)
+ UnoRuntime.queryInterface(XSingleServiceFactory.class,xSetCont);
+
+ Object xNewChild = xChildfactory.createInstance();
+
+ xSetCont.insertByName(groupName, xNewChild);
+
+ xChildAccess = (XNameReplace)
+ UnoRuntime.queryInterface(XNameContainer.class,xNewChild);
+ }
+
+ return xChildAccess;
+ }
+
+ /**
+ * Update a property of a group container of a set container
+ * @param setName the name of the <CODE>set</CODE> which containes the <CODE>group</CODE>
+ * @param groupName the name of the <CODE>group</CODE> which property should be changed
+ * @param propName the name of the property which should be changed
+ * @param propValue the value the property should get
+ * @throws com.sun.star.uno.Exception throws <CODE>com.sun.star.uno.Exeception</CODE> on any error.
+ */
+ public void updateGroupProperty(String setName,
+ String groupName,
+ String propName,
+ Object propValue)
+ throws com.sun.star.uno.Exception
+ {
+ XNameContainer xSetCont = this.getSet(setName);
+
+ XPropertySet xProp = null;
+ try {
+ xProp = (XPropertySet)UnoRuntime.queryInterface(
+ XPropertySet.class,
+ xSetCont.getByName(groupName));
+ } catch (com.sun.star.container.NoSuchElementException e){
+ throw new com.sun.star.uno.Exception(
+ "could not get group '" + groupName +
+ "' from set '"+ setName +"':\n" + e.toString());
+ }
+ try{
+ xProp.setPropertyValue(propName, propValue);
+ } catch (com.sun.star.uno.Exception e) {
+ throw new com.sun.star.uno.Exception(
+ "could not set property '" + propName +
+ "' from group '"+ groupName +
+ "' from set '"+ setName +"':\n" + e.toString());
+ }
+ }
+
+
+ /**
+ * Insert a property in an extensible group container or else update it
+ * @param setName the name of the <CODE>set</CODE> which containes the <CODE>group</CODE>
+ * @param group The name of the <CODE>group</CODE> which conatins the <CODE>extensible group</CODE>.
+ * @param extGroup The name of the <CODE>extensible group</CODE> which
+ * [should] contain the property
+ * @param propName The name of the property.
+ * @param propValue The value of the property.
+ * @throws com.sun.star.uno.Exception throws <CODE>com.sun.star.uno.Exeception</CODE> on any error.
+ */
+ public void insertOrUpdateExtensibleGroupProperty(
+ String setName,
+ String group,
+ String extGroup,
+ String propName,
+ Object propValue)
+ throws com.sun.star.uno.Exception
+ {
+ XNameContainer xSetCont = this.getSet(setName);
+
+ XNameReplace xGroupAccess = null;
+ XNameContainer xExtGroupCont = null;
+
+ try {
+ Object xGroup=xSetCont.getByName(group);
+ xGroupAccess = (XNameReplace) UnoRuntime.queryInterface(
+ XNameReplace.class,xGroup);
+ } catch(com.sun.star.container.NoSuchElementException e) {
+ throw new com.sun.star.uno.Exception(
+ "could not get group '" + group +
+ "' from set '"+ setName +"':\n" + e.toString());
+ }
+
+ try {
+ Object xGroup=xGroupAccess.getByName(extGroup);
+ xExtGroupCont = (XNameContainer) UnoRuntime.queryInterface(
+ XNameContainer.class,xGroup);
+ } catch(com.sun.star.container.NoSuchElementException e) {
+ throw new com.sun.star.uno.Exception(
+ "could not get extensilbe group '"+extGroup+
+ "' from group '"+ group +
+ "' from set '"+ setName +"':\n" + e.toString());
+ }
+
+ try {
+ xExtGroupCont.insertByName(propName, propValue);
+ }
+ catch(com.sun.star.container.ElementExistException e) {
+ xExtGroupCont .replaceByName(propName, propValue);
+ }
+
+ }
+
+
+ /**
+ * Returns a <CODE>XNameContainer</CODE> of the <CODE>Set</CODE>
+ * of the <CODE>Configuration</CODE>
+ * @param setName the name of the Set which sould be returned
+ * @throws com.sun.star.uno.Exception on any error
+ * @return A XNameContainer of the Set
+ */
+ public XNameContainer getSet(String setName)
+ throws com.sun.star.uno.Exception
+ {
+ XNameReplace xCont = (XNameReplace)
+ UnoRuntime.queryInterface(XNameReplace.class, m_xConfig);
+
+ Object oSet = xCont.getByName(setName);
+
+ if (oSet == null)
+ throw new com.sun.star.uno.Exception(
+ "could not get set '" + setName + ": null");
+
+ return (XNameContainer) UnoRuntime.queryInterface(
+ XNameContainer.class, oSet);
+
+ }
+}
diff --git a/qadevOOo/runner/helper/ConfigurationRead.java b/qadevOOo/runner/helper/ConfigurationRead.java
new file mode 100644
index 000000000000..e82fe6141b72
--- /dev/null
+++ b/qadevOOo/runner/helper/ConfigurationRead.java
@@ -0,0 +1,141 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package helper;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.container.XHierarchicalNameAccess;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.container.NoSuchElementException;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.PropertyState;
+import com.sun.star.uno.UnoRuntime;
+
+/**
+ * Read configuration settings.
+ */
+public class ConfigurationRead {
+
+ XHierarchicalNameAccess root = null;
+
+ /**
+ * Creates new ConfigurationRead
+ * @param xMSF An instance of service
+ * "com.sun.star.configuration.ConfigurationProvider"
+ * @param rootnode The root of the configuration nodes.
+ */
+ public ConfigurationRead(XMultiServiceFactory xMSF, String rootnode) {
+
+ PropertyValue [] nodeArgs = new PropertyValue [1];
+ PropertyValue nodepath = new PropertyValue();
+ nodepath.Name = "nodepath";
+ nodepath.Value = rootnode;
+ nodepath.Handle = -1;
+ nodepath.State = PropertyState.DEFAULT_VALUE;
+ nodeArgs[0]=nodepath;
+
+ try {
+ Object rootObject = xMSF.createInstanceWithArguments(
+ "com.sun.star.configuration.ConfigurationAccess",
+ nodeArgs);
+
+ root = (XHierarchicalNameAccess)
+ UnoRuntime.queryInterface(
+ XHierarchicalNameAccess.class, rootObject);
+ }
+ catch(com.sun.star.uno.Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Creates new ConfigurationRead. This uses "org.openoffice.Setup"
+ * as default root name.
+ * @param xMSF An instance of service
+ * "com.sun.star.configuration.ConfigurationProvider"
+ */
+ public ConfigurationRead(XMultiServiceFactory xMSF) {
+ this(xMSF, "org.openoffice.Setup");
+ }
+
+ /**
+ * Does the node with this hierarchical name exist?
+ * @param name The hierarchical name of a subnode.
+ * @return True, if the node exists.
+ */
+ public boolean hasByHieracrhicalName(String name) throws NoSuchElementException,
+ com.sun.star.lang.WrappedTargetException {
+
+ return root.hasByHierarchicalName(name);
+
+ }
+
+
+ /**
+ * Get the elements of the root node.
+ * @return All elements of the root node.
+ */
+ public String[] getRootNodeNames() {
+
+ XNameAccess xName = (XNameAccess)
+ UnoRuntime.queryInterface(XNameAccess.class, root);
+ String[]names = xName.getElementNames();
+ return names;
+ }
+
+ /**
+ * Get all elements of this node
+ * @param name The name of the node
+ * @return All elements of this node (as hierarchical names).
+ */
+ public String[] getSubNodeNames(String name) {
+ String[]names = null;
+ try {
+
+ Object next = root.getByHierarchicalName(name);
+ XNameAccess x = (XNameAccess)UnoRuntime.queryInterface(
+ XNameAccess.class, next);
+ names = x.getElementNames();
+ for (int i=0; i< names.length; i++) {
+ names[i] = name + "/" + names[i];
+ }
+ }
+ catch(Exception e) {
+ //just return null, if there are no further nodes
+ }
+ return names;
+ }
+
+ /**
+ * Get contents of a node by its hierarchical name.
+ * @param The hierarchical name of the node.
+ * @return The contents as an object
+ */
+ public Object getByHierarchicalName(String name) throws NoSuchElementException {
+ return root.getByHierarchicalName(name);
+ }
+
+}
diff --git a/qadevOOo/runner/helper/ContextMenuInterceptor.java b/qadevOOo/runner/helper/ContextMenuInterceptor.java
new file mode 100644
index 000000000000..a14685365c74
--- /dev/null
+++ b/qadevOOo/runner/helper/ContextMenuInterceptor.java
@@ -0,0 +1,140 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+package helper;
+
+import com.sun.star.beans.UnknownPropertyException;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.XIndexContainer;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.ui.ActionTriggerSeparatorType;
+import com.sun.star.ui.ContextMenuInterceptorAction;
+import com.sun.star.ui.XContextMenuInterceptor;
+import com.sun.star.uno.UnoRuntime;
+
+public class ContextMenuInterceptor implements XContextMenuInterceptor {
+
+ public ContextMenuInterceptorAction notifyContextMenuExecute(
+ com.sun.star.ui.ContextMenuExecuteEvent aEvent ) throws RuntimeException {
+ try {
+ // Retrieve context menu container and query for service factory to
+ // create sub menus, menu entries and separators
+ XIndexContainer xContextMenu = aEvent.ActionTriggerContainer;
+ XMultiServiceFactory xMenuElementFactory =
+ (XMultiServiceFactory)UnoRuntime.queryInterface(
+ XMultiServiceFactory.class, xContextMenu );
+
+ if ( xMenuElementFactory != null ) {
+
+ // create root menu entry for sub menu and sub menu
+ XPropertySet xRootMenuEntry =
+ (XPropertySet)UnoRuntime.queryInterface(
+ XPropertySet.class,
+ xMenuElementFactory.createInstance("com.sun.star.ui.ActionTrigger" ));
+
+ // create a line separator for our new help sub menu
+ XPropertySet xSeparator =
+ (XPropertySet)UnoRuntime.queryInterface(
+ XPropertySet.class,
+ xMenuElementFactory.createInstance("com.sun.star.ui.ActionTriggerSeparator" ) );
+ Short aSeparatorType = new Short( ActionTriggerSeparatorType.LINE );
+ xSeparator.setPropertyValue( "SeparatorType", (Object)aSeparatorType );
+
+ // query sub menu for index container to get access
+ XIndexContainer xSubMenuContainer =
+ (XIndexContainer)UnoRuntime.queryInterface(
+ XIndexContainer.class,
+ xMenuElementFactory.createInstance("com.sun.star.ui.ActionTriggerContainer" ));
+
+ // intialize root menu entry "Help"
+ xRootMenuEntry.setPropertyValue( "Text", new String( "Help" ));
+ xRootMenuEntry.setPropertyValue( "CommandURL", new String( "slot:5410" ));
+ xRootMenuEntry.setPropertyValue( "HelpURL", new String( "5410" ));
+ xRootMenuEntry.setPropertyValue( "SubContainer", (Object)xSubMenuContainer );
+
+ // create menu entries for the new sub menu
+ // intialize help/content menu entry
+ // entry "Content"
+ XPropertySet xMenuEntry = (XPropertySet)UnoRuntime.queryInterface(
+ XPropertySet.class, xMenuElementFactory.createInstance(
+ "com.sun.star.ui.ActionTrigger" ));
+ xMenuEntry.setPropertyValue( "Text", new String( "Content" ));
+ xMenuEntry.setPropertyValue( "CommandURL", new String( "slot:5401" ));
+ xMenuEntry.setPropertyValue( "HelpURL", new String( "5401" ));
+
+ // insert menu entry to sub menu
+ xSubMenuContainer.insertByIndex( 0, (Object)xMenuEntry );
+
+ // intialize help/help agent
+ // entry "Help Agent"
+ xMenuEntry = (XPropertySet)UnoRuntime.queryInterface(
+ XPropertySet.class,
+ xMenuElementFactory.createInstance("com.sun.star.ui.ActionTrigger" ));
+ xMenuEntry.setPropertyValue( "Text", new String( "Help Agent" ));
+ xMenuEntry.setPropertyValue( "CommandURL", new String( "slot:5962" ));
+ xMenuEntry.setPropertyValue( "HelpURL", new String( "5962" ));
+
+ // insert menu entry to sub menu
+ xSubMenuContainer.insertByIndex( 1, (Object)xMenuEntry );
+ // intialize help/tips
+ // entry "Tips"
+ xMenuEntry = (XPropertySet)UnoRuntime.queryInterface(
+ XPropertySet.class,
+ xMenuElementFactory.createInstance("com.sun.star.ui.ActionTrigger" ));
+ xMenuEntry.setPropertyValue( "Text", new String( "Tips" ));
+ xMenuEntry.setPropertyValue( "CommandURL", new String( "slot:5404" ));
+ xMenuEntry.setPropertyValue( "HelpURL", new String( "5404" ));
+
+ // insert menu entry to sub menu
+ xSubMenuContainer.insertByIndex( 2, (Object)xMenuEntry );
+
+ // add separator into the given context menu
+ xContextMenu.insertByIndex( 1, (Object)xSeparator );
+
+ // add new sub menu into the given context menu
+ xContextMenu.insertByIndex( 1, (Object)xRootMenuEntry );
+
+ // The controller should execute the modified context menu and stop notifying other
+ // interceptors.
+ return ContextMenuInterceptorAction.EXECUTE_MODIFIED ;
+ }
+ } catch ( UnknownPropertyException ex ) {
+ // do something useful
+ // we used a unknown property
+ } catch ( IndexOutOfBoundsException ex ) {
+ // do something useful
+ // we used an invalid index for accessing a container
+ } catch ( Exception ex ) {
+ // something strange has happend!
+ } catch ( Throwable ex ) {
+ // catch java exceptions and do something useful
+ }
+
+ return ContextMenuInterceptorAction.IGNORED;
+ }
+} \ No newline at end of file
diff --git a/qadevOOo/runner/helper/CwsDataExchangeImpl.java b/qadevOOo/runner/helper/CwsDataExchangeImpl.java
new file mode 100644
index 000000000000..15292f20d725
--- /dev/null
+++ b/qadevOOo/runner/helper/CwsDataExchangeImpl.java
@@ -0,0 +1,157 @@
+/*
+ *************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package helper;
+
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.ArrayList;
+import lib.TestParameters;
+import share.CwsDataExchange;
+import share.LogWriter;
+import util.PropertyName;
+import util.utils;
+
+/**
+ * Implementaion of the interface CwsDataExchange
+ * @see share.CwsDataExchange
+ */
+public class CwsDataExchangeImpl implements CwsDataExchange
+{
+
+ private final String cwsName;
+ private final TestParameters param;
+ private final LogWriter log;
+ private final BuildEnvTools bet;
+ private final boolean mDebug;
+
+ public CwsDataExchangeImpl(String cwsName, TestParameters param, LogWriter log) throws ParameterNotFoundException
+ {
+ this.cwsName = cwsName;
+ this.param = param;
+ this.log = log;
+ this.bet = new BuildEnvTools(param, log);
+ mDebug = param.getBool(PropertyName.DEBUG_IS_ACTIVE);
+ }
+
+ public ArrayList getModules()
+ {
+ // the cwstouched command send its version information to StdErr.
+ // A piping from StdErr to SdtOut the tcsh does not support.
+ // To find the output easily the echo command is used
+ final String[] commands =
+ {
+ "echo cwstouched starts here",
+ "cwstouched",
+ "echo cwstouched ends here"
+ };
+
+ final ProcessHandler procHdl = bet.runCommandsInEnvironmentShell(commands, null, 20000);
+
+ if (mDebug)
+ {
+ log.println("---> Output of getModules:");
+ log.println(procHdl.getOutputText());
+ log.println("<--- Output of getModules");
+ log.println("---> Error output of getModules");
+ log.println(procHdl.getErrorText());
+ log.println("<--- Error output of getModules");
+ }
+
+ final String[] outs = procHdl.getOutputText().split("\n");
+
+ final ArrayList<String> moduleNames = new ArrayList<String>();
+ boolean bStart = false;
+ for (int i = 0; i < outs.length; i++)
+ {
+ final String line = outs[i];
+ if (line.startsWith("cwstouched starts here"))
+ {
+ bStart = true;
+ continue;
+ }
+ if (line.startsWith("cwstouched ends here"))
+ {
+ bStart = false;
+ continue;
+ }
+ if (bStart && line.length() > 1)
+ {
+ moduleNames.add(line);
+ }
+ }
+
+ return moduleNames;
+ }
+
+ public void setUnoApiCwsStatus(boolean status)
+ {
+
+ FileWriter out = null;
+ String statusFile = null;
+ try
+ {
+
+ final String stat = status ? ".PASSED.OK" : ".PASSED.FAILED";
+
+ statusFile = utils.getUsersTempDir() +
+ System.getProperty("file.separator") +
+ "UnoApiCwsStatus." +
+ (String) param.get(PropertyName.VERSION) +
+ "_" + param.get(PropertyName.OPERATING_SYSTEM) + stat + ".txt";
+
+ out = new FileWriter(statusFile);
+
+ out.write(stat);
+ out.flush();
+ out.close();
+
+ final String[] commands =
+ {
+ "cwsattach " + statusFile
+ };
+
+ bet.runCommandsInEnvironmentShell(commands, null, 5000);
+
+ }
+ catch (IOException ex)
+ {
+ System.out.println("ERROR: could not attach file '" + statusFile + "' to cws\n" + ex.toString());
+ }
+ finally
+ {
+ try
+ {
+ out.close();
+ }
+ catch (IOException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+ }
+}
diff --git a/qadevOOo/runner/helper/FileTools.java b/qadevOOo/runner/helper/FileTools.java
new file mode 100644
index 000000000000..0a6b4dd96577
--- /dev/null
+++ b/qadevOOo/runner/helper/FileTools.java
@@ -0,0 +1,160 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package helper;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+
+/**
+ * This class deliver some functionality to copy files.
+ */
+public class FileTools {
+
+ /**
+ * Copies all files under srcDir to dstDir.
+ * If dstDir does not exist, it will be created.
+ * @param srcDir the source directory
+ * @param dstDir the destination direcotry
+ * @throws java.io.IOException throws java.io.IOException if something failes
+ */
+ public static void copyDirectory(File srcDir, File dstDir)
+ throws java.io.IOException {
+ copyDirectory(srcDir, dstDir, new String[]{});
+ }
+ /**
+ * Copies all files under srcDir to dstDir except Files given in the
+ * ignore list. This files will not be copied.
+ * If dstDir does not exist, it will be created.
+ * @param srcDir the source directory
+ * @param dstDir the destination direcotry
+ * @param ignore a list of files which should not be copied
+ * @throws java.io.IOException throws java.io.IOException if something failes
+ */
+ public static void copyDirectory(File srcDir, File dstDir, String[] ignore)
+ throws java.io.IOException {
+
+ for (int i=0; i<ignore.length;i++){
+ if (srcDir.getName().endsWith(ignore[i])) {
+ return;
+ }
+ }
+
+ if (srcDir.isDirectory()) {
+ if (!dstDir.exists()) {
+ dstDir.mkdir();
+ }
+
+ String[] files = srcDir.list();
+ for (int i=0; i< files.length; i++) {
+ copyDirectory(new File(srcDir, files[i]), new File(dstDir, files[i]), ignore);
+ }
+ } else {
+ // This method is implemented in e1071 Copying a File
+ copyFile(srcDir, dstDir);
+ }
+ }
+
+ /**
+ * Copies src file to dst file. If the dst file does not exist, it is created
+ * @param src the source file
+ * @param dst the destination file
+ * @throws java.io.IOException throws java.io.IOException if something failes
+ */
+ public static void copyFile(File src, File dst) throws java.io.IOException {
+ InputStream in = new FileInputStream(src);
+ OutputStream out = new FileOutputStream(dst);
+
+ // Transfer bytes from in to out
+ byte[] buf = new byte[1024];
+ int len;
+ while ((len = in.read(buf)) > 0) {
+ out.write(buf, 0, len);
+ }
+ in.close();
+ out.close();
+ }
+ /**
+ * Deletes all files and subdirectories under dir and the directory itself.
+ * Returns true if all deletions were successful.
+ * If the deletion fails, the method the method continues to delete rest
+ * of the files and returns false.
+ * @return Returns true if all deletions were successful, else false.
+ * @param dir the directory to delete
+ */
+ public static boolean deleteDir(File dir) {
+
+ // if (! cleanDir(dir)) return false;
+
+ // The directory is now empty so delete it
+ // return dir.delete();
+ return cleanDir(dir);
+ }
+
+ /**
+ * Deletes all files and subdirectories under dir.
+ * Returns true if all deletions were successful.
+ * If a deletion fails, the method continues to delete rest of the files.
+ * @return Returns true if all deletions were successful, else false.
+ * @param dir the directory to clean from content
+ */
+ // public static boolean cleanDir(File dir){
+ //
+ // boolean success = true;
+ // if (dir.isDirectory()){
+ // File [] theFiles = dir.listFiles();
+ //
+ // if (theFiles.length != 0 )
+ // for (int i = 0; i < theFiles.length; i++){
+ // success &= theFiles[i].delete();
+ // }
+ // }
+ // return success;
+ // }
+
+ public static boolean cleanDir(File dir)
+ {
+ if (dir.isDirectory())
+ {
+ String[] children = dir.list();
+ for (int i=0; i<children.length; i++)
+ {
+ boolean success = cleanDir(new File(dir, children[i]));
+ if (!success)
+ {
+ return false;
+ }
+ }
+ }
+
+ // The directory is now empty so delete it
+ return dir.delete();
+ }
+}
diff --git a/qadevOOo/runner/helper/InetTools.java b/qadevOOo/runner/helper/InetTools.java
new file mode 100644
index 000000000000..56c964c8f4db
--- /dev/null
+++ b/qadevOOo/runner/helper/InetTools.java
@@ -0,0 +1,88 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package helper;
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.UnoRuntime;
+
+// access the implementations via names
+import com.sun.star.util.XChangesBatch;
+
+import lib.TestParameters;
+
+
+public class InetTools {
+ /**
+ * Helper method: sets the HTTP-Proxy to values from
+ * <code>lib.TestParameters</code>
+ */
+ public static boolean setHTTPProxy(TestParameters param){
+ XMultiServiceFactory xMSF = (XMultiServiceFactory) param.getMSF();
+ PropertyValue[] ProvArgs = new PropertyValue[1];
+ PropertyValue Arg = new PropertyValue();
+ Arg.Name = "nodepath";
+ Arg.Value = "/org.openoffice.Inet/Settings";
+ ProvArgs[0] = Arg;
+
+ try {
+ Object oProvider = xMSF.createInstance(
+ "com.sun.star.configuration.ConfigurationProvider");
+
+ XMultiServiceFactory oProviderMSF = (XMultiServiceFactory) UnoRuntime.queryInterface(
+ XMultiServiceFactory.class,
+ oProvider);
+
+ Object oInet = oProviderMSF.createInstanceWithArguments(
+ "com.sun.star.configuration.ConfigurationUpdateAccess",
+ ProvArgs);
+
+ XPropertySet oInetProps = (XPropertySet) UnoRuntime.queryInterface(
+ XPropertySet.class, oInet);
+
+ String HTTPProxyName = (String)param.get("HTTPProxyName");
+ String HTTPProxyPort = (String)param.get("HTTPProxyPort");
+
+ if ((HTTPProxyName == null) || (HTTPProxyPort == null)) {
+ return false;
+ }
+
+ oInetProps.setPropertyValue("ooInetHTTPProxyName", HTTPProxyName);
+ oInetProps.setPropertyValue("ooInetHTTPProxyPort", HTTPProxyPort);
+ oInetProps.setPropertyValue("ooInetProxyType", new Long(2));
+
+ XChangesBatch oSecureChange = (XChangesBatch) UnoRuntime.queryInterface(
+ XChangesBatch.class, oInet);
+ oSecureChange.commitChanges();
+ }
+ catch(com.sun.star.uno.Exception e) {
+ e.printStackTrace();
+ }
+ return true;
+ }
+}
diff --git a/qadevOOo/runner/helper/LoggingThread.java b/qadevOOo/runner/helper/LoggingThread.java
new file mode 100644
index 000000000000..39536179545c
--- /dev/null
+++ b/qadevOOo/runner/helper/LoggingThread.java
@@ -0,0 +1,96 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package helper;
+
+import share.*;
+import lib.TestParameters;
+import util.PropertyName;
+import util.utils;
+
+/**
+ * This class is printing to a <CODE>LogWriter</CODE>. This could be usefull if a UNO-API
+ * function runns longer the the time out. To avoid the assumption of death applikation
+ * a simple string is logged for 100 times of time out.</br>
+ * Example:</br>
+ * logger = new LoggingThread((LogWriter)log, tParam);
+ * logger.start();
+ * oObj.longRunningFunction();
+ * logger.finish();
+ *
+ */
+public class LoggingThread extends Thread {
+
+ TestParameters param;
+ LogWriter log = null;
+ boolean finished = false;
+ boolean debug = false;
+
+ /**
+ *
+ * @param log
+ * @param tParam
+ */
+ public LoggingThread(LogWriter log, TestParameters tParam) {
+ this.log = log;
+ this.param = tParam;
+ this.debug = tParam.getBool(PropertyName.DEBUG_IS_ACTIVE);
+ }
+
+ public void run() {
+ final int timeOut = param.getInt(PropertyName.TIME_OUT) / 2;
+ int count = 0;
+ finished = false;
+ if (debug) log.println("TimeOutLogger: " + utils.getDateTime() + " start");
+ while (!finished && count < 200) {
+ try {
+ if (debug) log.println("TimeOutLogger: "+utils.getDateTime() + count);
+ synchronized (this) {
+ wait(timeOut);
+ }
+ count++;
+ } catch (InterruptedException ex) {
+ }
+ }
+ if (debug) log.println("TimeOutLogger: " + utils.getDateTime() + " finished");
+ }
+
+ /**
+ * finished the LoggingThread
+ */
+ public void finish() {
+ try {
+ finished = true;
+ synchronized (this) {
+ notify();
+ }
+ if (debug) log.println("TimeOutLogger: " + utils.getDateTime() + " try to finish ");
+ sleep(1000);
+ } catch (InterruptedException ex) {
+ }
+ }
+}
diff --git a/qadevOOo/runner/helper/OSHelper.java b/qadevOOo/runner/helper/OSHelper.java
new file mode 100644
index 000000000000..d8e467ae4584
--- /dev/null
+++ b/qadevOOo/runner/helper/OSHelper.java
@@ -0,0 +1,88 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package helper;
+
+/**
+ * Helper object, to identify the current Operation System.
+ * @author ll93751
+ */
+public class OSHelper
+{
+ public static boolean isWindows()
+ {
+ String sOSName = System.getProperty("os.name");
+ if (sOSName.toLowerCase().startsWith("windows"))
+ {
+ return true;
+ }
+ return false;
+ }
+ // not need
+ // public static boolean isUnix()
+ public static boolean isSolarisIntel()
+ {
+ if ( ( System.getProperty("os.name").toLowerCase().startsWith("solaris") ||
+ System.getProperty("os.name").toLowerCase().startsWith("sunos") ) &&
+ System.getProperty("os.arch").equals("x86"))
+ {
+ return true;
+ }
+ return false;
+ }
+ public static boolean isSolarisSparc()
+ {
+ if ( ( System.getProperty("os.name").toLowerCase().startsWith("solaris") ||
+ System.getProperty("os.name").toLowerCase().startsWith("sunos") ) &&
+ System.getProperty("os.arch").equals("sparc"))
+ {
+ return true;
+ }
+ return false;
+ }
+ public static boolean isLinuxIntel()
+ {
+ if (System.getProperty("os.name").toLowerCase().startsWith("linux") &&
+ System.getProperty("os.arch").equals("i386"))
+ {
+ return true;
+ }
+ return false;
+ }
+
+ public static boolean isUnix()
+ {
+ if (isLinuxIntel() ||
+ isSolarisIntel() ||
+ isSolarisSparc())
+ {
+ return true;
+ }
+ return false;
+ }
+
+}
diff --git a/qadevOOo/runner/helper/ObjectInspectorModelImpl.java b/qadevOOo/runner/helper/ObjectInspectorModelImpl.java
new file mode 100644
index 000000000000..5075c50e795b
--- /dev/null
+++ b/qadevOOo/runner/helper/ObjectInspectorModelImpl.java
@@ -0,0 +1,145 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************
+ */
+
+package helper;
+
+import com.sun.star.inspection.PropertyCategoryDescriptor;
+import com.sun.star.inspection.XObjectInspectorModel;
+
+/**
+ * This is an implementation of <CODE>ObjectInspectorModel</CODE>.
+ * @see com.sun.star.inspection.XObjectInspectorModel
+ */
+public class ObjectInspectorModelImpl implements XObjectInspectorModel{
+
+ /**
+ * class variable which contains the implementations of
+ * <CODE>PropertyCategoryDescriptor</CODE>
+ * @see com.sun.star.inspection.PropertyCategoryDescriptor
+ */
+ PropertyCategoryDescriptor[] m_Categories;
+
+ /**
+ * class variable which contains the count of implementations of
+ * <CODE>PropertyCategoryDescriptor</CODE>
+ */
+ int m_count;
+
+ /**
+ * Creates a new instance of ObjectInspectorModelImpl
+ * For every count given in parameter <CODE>count</CODE> an
+ * <CODE>PropertyCategoryDescriptor</CODE> was created an filled with valuable content.
+ * @param count count of <CODE>PropertyCategoryDescriptor</CODE> to create
+ */
+ public ObjectInspectorModelImpl(int count) {
+ m_count = count;
+ m_Categories = new PropertyCategoryDescriptor[m_count];
+ int CategoryMem = 0;
+ int inCat = 0;
+ for (int n=0; n < m_count; n++ ){
+
+ m_Categories[n] = new PropertyCategoryDescriptor();
+
+ int category = n / 2;
+ inCat =(CategoryMem == category)? ++inCat: 1;
+ CategoryMem = category;
+
+ //System.out.println("Category" + category + "Number" + inCat);
+ m_Categories[n].ProgrammaticName = "Category" + category;
+ m_Categories[n].UIName = "Category" + category + "Number" + inCat;
+ m_Categories[n].HelpURL = "h:" + n;
+ }
+ }
+
+ /**
+ * returns the catrgories
+ * @return returns the catrgories
+ */
+ public PropertyCategoryDescriptor[] describeCategories() {
+ return m_Categories;
+ }
+
+ /**
+ * returns currently nothing
+ * @return nothing
+ */
+ public Object[] getHandlerFactories() {
+ return null;
+ }
+
+ /** determines whether the object inspector should have a help section
+ @return false
+ */
+ public boolean getHasHelpSection() {
+ return false;
+ }
+
+ /** returns minimum number of lines in the help text section.
+ @return 3
+ */
+ public int getMinHelpTextLines() {
+ return 3;
+ };
+
+ /** returns maximum number of lines in the help text section.
+ @return 8
+ */
+ public int getMaxHelpTextLines() {
+ return 8;
+ };
+
+ /** returns whether or not the inspector's UI should be read-only
+ */
+ public boolean getIsReadOnly() {
+ return false;
+ }
+
+ /** sets the inspector's read-only state
+ */
+ public void setIsReadOnly( boolean _IsReadOnly ) {
+ // not supported, and not used so far in our test cases
+ }
+
+ /**
+ * retrieves an index in a global property ordering, for a given property name
+ * @param UIName the property whose global order index should be retrieved
+ * @throws com.sun.star.beans.UnknownPropertyException if the given property is unknown
+ * @return the global order index of PropertyName
+ */
+ public int getPropertyOrderIndex(String UIName) {
+ int index = 0;
+ for (int n=0; n < m_Categories.length; n++){
+ if (m_Categories[n].UIName.equals(UIName)){
+ index = n;
+ break;
+ }
+ }
+ return index;
+ }
+
+ }
diff --git a/qadevOOo/runner/helper/OfficeProvider.java b/qadevOOo/runner/helper/OfficeProvider.java
new file mode 100644
index 000000000000..8589de47ea82
--- /dev/null
+++ b/qadevOOo/runner/helper/OfficeProvider.java
@@ -0,0 +1,833 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package helper;
+
+//import com.sun.star.bridge.UnoUrlResolver;
+import com.sun.star.beans.XFastPropertySet;
+import com.sun.star.bridge.XUnoUrlResolver;
+import com.sun.star.container.XEnumeration;
+import com.sun.star.container.XEnumerationAccess;
+import com.sun.star.frame.XDesktop;
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.util.XCloseable;
+import com.sun.star.util.XStringSubstitution;
+
+import java.io.File;
+import java.io.PrintWriter;
+import java.util.StringTokenizer;
+
+import lib.TestParameters;
+
+import share.DescEntry;
+import share.LogWriter;
+
+import util.DynamicClassLoader;
+import util.PropertyName;
+import util.utils;
+
+/**
+ * This class will connect the office and start it if possible
+ *
+ */
+public class OfficeProvider implements AppProvider
+{
+
+ protected static boolean debug = false;
+
+ /**
+ * copy the user layer to a safe place, usualy to $TMP/user_backup$USER
+ * @param param
+ * @param msf
+ */
+ public void backupUserLayer(TestParameters param, XMultiServiceFactory msf)
+ {
+ try
+ {
+ final XStringSubstitution sts = createStringSubstitution(msf);
+ debug = param.getBool(PropertyName.DEBUG_IS_ACTIVE);
+
+ String userLayer = sts.getSubstituteVariableValue("$(user)");
+ userLayer = getDirSys(userLayer);
+ param.put("userLayer", userLayer);
+
+ final String copyLayer = util.utils.getUsersTempDir() + System.getProperty("file.separator") +
+ "user_backup" +
+ System.getProperty("user.name");
+ param.put("copyLayer", copyLayer);
+
+
+ dbg(" copy '" + userLayer + "' ->" + copyLayer + "'");
+ // Slow machines the copy job could spend some time. To avoid activating of OfficeWatcher it must be pinged
+ OfficeWatcherPing owp = new OfficeWatcherPing((OfficeWatcher) param.get(PropertyName.OFFICE_WATCHER));
+ owp.start();
+
+ deleteFilesAndDirector (new File(copyLayer));
+ FileTools.copyDirectory(new File(userLayer), new File(copyLayer), new String[]
+ {
+ "temp"
+ });
+
+ owp.finish();
+
+ }
+ catch (com.sun.star.container.NoSuchElementException e)
+ {
+ System.out.println("User Variable '$(user)' not defined.");
+ }
+ catch (java.io.IOException e)
+ {
+ System.out.println("Couldn't backup user layer");
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Dispose the office.
+ * This method can only be used, if the office was connected in the first
+ * place: getManager() was called first.
+ * @param param
+ * @return return true if desktop is terminates, else false
+ */
+ public boolean disposeManager(lib.TestParameters param)
+ {
+
+ XMultiServiceFactory msf = (XMultiServiceFactory) param.getMSF();
+
+ if (msf == null)
+ {
+ return true;
+ }
+ else
+ {
+ XDesktop desk = null;
+
+ try
+ {
+ desk = UnoRuntime.queryInterface(XDesktop.class, msf.createInstance("com.sun.star.frame.Desktop"));
+ }
+ catch (com.sun.star.uno.Exception ue)
+ {
+ return false;
+ }
+
+ msf = null;
+
+ if (desk != null)
+ {
+ desk.terminate();
+
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ }
+
+ /**
+ * Method to get the ServiceManager of an Office
+ * @param param
+ * @return
+ */
+ 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");
+
+ if (additionalArgs == null)
+ {
+ additionalArgs = ";";
+ }
+ else
+ {
+ additionalArgs = "," + additionalArgs + ";";
+ }
+
+ final String cncstr = "uno:" + param.get("ConnectionString") + ";urp" +
+ additionalArgs + "StarOffice.ServiceManager";
+
+ System.out.println("Connecting the Office with " + cncstr);
+
+ XMultiServiceFactory msf = connectOffice(cncstr);
+
+ // if the office is running and the office crashes while testing it could
+ // be usesfull to restart the office if possible and continuing the tests.
+ // 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))
+ {
+ makeAppExecCommand(msf, param);
+ }
+
+ 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)
+ {
+ 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)
+ {
+ ow_old.finish = true;
+ }
+
+ final String cmd = (String) param.get("AppExecutionCommand");
+ dbg("AppExecutionCommand: " + cmd);
+ // 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"))
+ {
+ System.out.println(errorMessage);
+ return null;
+ }
+ bAppExecutionHasWarning = !errorMessage.equals("OK");
+
+ final DynamicClassLoader dcl = new DynamicClassLoader();
+ final LogWriter log = (LogWriter) dcl.getInstance(
+ (String) param.get("LogWriter"));
+
+ //create empty entry
+ final DescEntry Entry = new DescEntry();
+ Entry.entryName = "office";
+ Entry.longName = "office";
+ Entry.EntryType = "placebo";
+ Entry.isOptional = false;
+ Entry.isToTest = false;
+ Entry.SubEntryCount = 0;
+ Entry.hasErrorMsg = false;
+ Entry.State = "non possible";
+ Entry.UserDefinedParams = param;
+
+ log.initialize(Entry, debug);
+
+ final ProcessHandler ph = new ProcessHandler(cmd, (PrintWriter) log);
+ isExecutable = ph.executeAsynchronously();
+
+ if (isExecutable)
+ {
+ param.put("AppProvider", ph);
+ final OfficeWatcher ow = new OfficeWatcher(param);
+ param.put("Watcher", ow);
+ ow.start();
+ ow.ping();
+ }
+
+ int k = 0;
+
+ // wait up to 21 seconds to get an office connection
+ while ((k < 42) && (msf == null))
+ {
+ try
+ {
+ msf = connect(cncstr);
+ }
+ catch (com.sun.star.uno.Exception ue)
+ {
+ exConnectFailed = ue;
+ exc = ue.getMessage();
+ }
+ catch (java.lang.Exception je)
+ {
+ exConnectFailed = je;
+ exc = je.getMessage();
+ }
+ if (msf == null)
+ {
+ try
+ {
+ Thread.sleep(k * 500);
+ }
+ catch (InterruptedException ex)
+ {
+ }
+ }
+ k++;
+ }
+
+ if (msf == null)
+ {
+ System.out.println("Exception while connecting.\n" + exConnectFailed);
+ if (exc != null)
+ {
+ System.out.println(exc);
+ }
+ if (bAppExecutionHasWarning)
+ {
+ System.out.println(errorMessage);
+ }
+ }
+ else if (isExecutable)
+ {
+ 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").
+ concat("\nsoffice -accept=").concat((String) param.get("ConnectionString")).concat(";urp;\n"));
+ if (bAppExecutionHasWarning)
+ {
+ System.out.println(errorMessage);
+ }
+ }
+ }
+
+ return msf;
+ }
+
+ /**
+ * 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
+ {
+
+ // Get component context
+ final XComponentContext xcomponentcontext = com.sun.star.comp.helper.Bootstrap.createInitialComponentContext(null);
+
+ // initial serviceManager
+ final XMultiComponentFactory xLocalServiceManager = xcomponentcontext.getServiceManager();
+
+ // 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);
+ final XUnoUrlResolver urlResolver = UnoRuntime.queryInterface(XUnoUrlResolver.class, xUrlResolver);
+
+ final Object rInitialObject = urlResolver.resolve(connectStr);
+
+ XMultiServiceFactory xMSF = null;
+
+ if (rInitialObject != null)
+ {
+ debug = true;
+ dbg("resolved url");
+
+ xMSF = UnoRuntime.queryInterface(XMultiServiceFactory.class, rInitialObject);
+ }
+
+ return xMSF;
+ }
+
+ /**
+ * Close an office.
+ * @param param The test parameters.
+ * @param closeIfPossible If true, close even if
+ * it was running before the test
+ */
+ 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)
+ {
+ dbg("try to get ProcessHandler");
+
+ final ProcessHandler ph = (ProcessHandler) param.get("AppProvider");
+
+ if (ph != null)
+ {
+ dbg("ProcessHandler != null");
+
+ disposeOffice(msf, param);
+
+ // dispose watcher in case it's still running.
+ dbg("try to get OfficeWatcher");
+
+ final OfficeWatcher ow = (OfficeWatcher) param.get("Watcher");
+
+ if ((ow != null) && ow.isAlive())
+ {
+ dbg("OfficeWatcher will be finished");
+ ow.finish = true;
+ }
+ else
+ {
+ dbg("OfficeWatcher seems to be finished");
+ }
+
+ return true;
+ }
+ else
+ {
+ if (closeIfPossible)
+ {
+ return disposeOffice(msf, param);
+ }
+ }
+ }
+ else
+ {
+ final String cncstr = "uno:" + param.get("ConnectionString") +
+ ";urp;StarOffice.ServiceManager";
+ dbg("try to connect office");
+ msf = connectOffice(cncstr);
+
+ if (closeIfPossible)
+ {
+ return disposeOffice(msf, param);
+ }
+ }
+ dbg("closeExistingOffice finished");
+ return true;
+ }
+
+ private XMultiServiceFactory connectOffice(String cncstr)
+ {
+ XMultiServiceFactory msf = null;
+ String exc = "";
+ debug = true;
+
+ dbg("trying to connect to " + cncstr);
+
+ try
+ {
+ msf = connect(cncstr);
+ }
+ catch (com.sun.star.uno.Exception ue)
+ {
+ exc = ue.getMessage();
+ }
+ catch (java.lang.Exception je)
+ {
+ exc = je.getMessage();
+ }
+
+ if (debug && exc != null && exc.length() != 0)
+ {
+ if (exc == null)
+ {
+ exc = "";
+ }
+ dbg("Could not connect an Office. " + exc);
+ }
+
+ return msf;
+ }
+
+ private synchronized boolean disposeOffice(XMultiServiceFactory msf,
+ TestParameters param)
+ {
+ XDesktop desk = null;
+
+ debug = param.getBool(PropertyName.DEBUG_IS_ACTIVE);
+
+ boolean result = true;
+
+ if (msf != null)
+ {
+
+ // disable QuickStarter
+ try
+ {
+ Object quickStarter = msf.createInstance("com.sun.star.office.Quickstart");
+ XFastPropertySet fps = UnoRuntime.queryInterface(XFastPropertySet.class, quickStarter);
+ fps.setFastPropertyValue(0, false);
+ }
+ catch (com.sun.star.uno.Exception ex)
+ {
+ dbg("ERROR: Could not disable QuickStarter: " + ex.toString());
+ }
+
+ try
+ {
+ desk = UnoRuntime.queryInterface(XDesktop.class, msf.createInstance("com.sun.star.frame.Desktop"));
+ msf = null;
+
+ if (desk != null)
+ {
+ final boolean allClosed = closeAllWindows(desk);
+
+ if (!allClosed)
+ {
+ dbg("Couldn't close all office windows!");
+ }
+
+ dbg("Trying to terminate the desktop");
+
+ desk.terminate();
+ dbg("Desktop terminated");
+
+ 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 (com.sun.star.uno.Exception ue)
+ {
+ result = false;
+ }
+ catch (com.sun.star.lang.DisposedException ue)
+ {
+ result = false;
+ }
+ }
+
+ final String AppKillCommand = (String) param.get(util.PropertyName.APP_KILL_COMMAND);
+ if (AppKillCommand != null)
+ {
+ String sAppKillCommand = StringHelper.removeSurroundQuoteIfExists(AppKillCommand);
+ final StringTokenizer aKillCommandToken = new StringTokenizer(sAppKillCommand, ";");
+ while (aKillCommandToken.hasMoreTokens())
+ {
+ final String sKillCommand = aKillCommandToken.nextToken();
+ dbg("User defined an application to destroy the started process. Trying to execute: " + sKillCommand);
+
+ final ProcessHandler pHdl = new ProcessHandler(sKillCommand, 1000); // 3000 seems to be too long
+ pHdl.runCommand();
+
+ pHdl.kill();
+ }
+ }
+
+ final ProcessHandler ph = (ProcessHandler) param.get("AppProvider");
+
+ if (ph != null)
+ {
+ // dispose watcher in case it's still running.
+ final OfficeWatcher ow = (OfficeWatcher) param.get("Watcher");
+
+ if ((ow != null) && ow.isAlive())
+ {
+ ow.finish = true;
+ }
+
+ ph.kill();
+ }
+
+ param.remove("AppProvider");
+ param.remove("ServiceFactory");
+
+ if (!param.getBool(util.PropertyName.DONT_BACKUP_USERLAYER))
+ {
+ //copy user_backup into user layer
+ try
+ {
+ final String userLayer = (String) param.get("userLayer");
+ final String copyLayer = (String) param.get("copyLayer");
+ if (userLayer != null && copyLayer != null)
+ {
+ deleteFilesAndDirector(new File(userLayer));
+ final File copyFile = new File(copyLayer);
+ dbg("copy '" + copyFile + "' -> '" + userLayer + "'");
+ FileTools.copyDirectory(copyFile, new File(userLayer), new String[]
+ {
+ "temp"
+ });
+ dbg("copy '" + copyFile + "' -> '" + userLayer + "' finished");
+
+ // remove all user_backup folder in temp dir
+ // this is for the case the runner was killed and some old backup folder still stay in temp dir
+
+
+ }
+ else
+ {
+ System.out.println("Cannot copy layer: '" + copyLayer + "' back to user layer: '" + userLayer + "'");
+ }
+ }
+ catch (java.io.IOException e)
+ {
+ dbg("Couldn't recover from backup\n" + e.getMessage());
+ }
+ }
+ return result;
+ }
+
+ protected boolean closeAllWindows(XDesktop desk)
+ {
+ final XEnumerationAccess compEnumAccess = desk.getComponents();
+ final XEnumeration compEnum = compEnumAccess.createEnumeration();
+ boolean res = true;
+
+ try
+ {
+ while (compEnum.hasMoreElements())
+ {
+ final XCloseable closer = UnoRuntime.queryInterface(XCloseable.class, compEnum.nextElement());
+
+ if (closer != null)
+ {
+ closer.close(true);
+ }
+ }
+ }
+ catch (com.sun.star.util.CloseVetoException cve)
+ {
+ res = false;
+ }
+ catch (com.sun.star.container.NoSuchElementException nsee)
+ {
+ res = false;
+ }
+ catch (com.sun.star.lang.WrappedTargetException wte)
+ {
+ res = false;
+ }
+
+ return res;
+ }
+
+ public static XStringSubstitution createStringSubstitution(XMultiServiceFactory xMSF)
+ {
+ Object xPathSubst = null;
+
+ try
+ {
+ xPathSubst = xMSF.createInstance(
+ "com.sun.star.util.PathSubstitution");
+ }
+ catch (com.sun.star.uno.Exception e)
+ {
+ e.printStackTrace();
+ }
+
+ if (xPathSubst != null)
+ {
+ return UnoRuntime.queryInterface(XStringSubstitution.class, xPathSubst);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ /**
+ * converts directory without 'file:///' prefix.
+ * and System dependend file separator
+ * @param dir
+ * @return
+ */
+ public static String getDirSys(String dir)
+ {
+ String sysDir = "";
+
+ final int idx = dir.indexOf("file://");
+
+ final int idx2 = dir.indexOf("file:///");
+
+ // remove leading 'file://'
+ if (idx < 0)
+ {
+ sysDir = dir;
+ }
+ else
+ {
+ sysDir = dir.substring("file://".length());
+ }
+
+ sysDir = utils.replaceAll13(sysDir, "%20", " ");
+
+ // append '/' if not there (e.g. linux)
+ 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))
+ {
+ sysDir = sysDir.substring(1);
+ }
+ else
+ {
+ //network path
+ sysDir = "//" + sysDir;
+ }
+ sysDir = sysDir.replace('/', '\\');
+ }
+
+ return sysDir;
+ }
+
+ /**
+ * If the office is connected but the <CODE>AppExecutionCommand</CODE> is not set,
+ * this function asks the office for its location and fill the
+ * <CODE>AppExecutionCommand</CODE> with valid contet.
+ * This function was only called if parameter <CODE>AutoRestart</CODE> is set.
+ * @param msf the <CODE>MultiServiceFactory</CODE>
+ * @param param the <CODE>TestParameters</CODE>
+ */
+ 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);
+
+ 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
+ {
+ sysBinDir = utils.getSystemURL(utils.expandMacro(msf, "$SYSBINDIR"));
+ }
+ 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)
+ {
+ command = sysBinDir + System.getProperty("file.separator") + "soffice" +
+ " -norestore -accept=" + connectionString + ";urp;";
+ }
+
+ dbg("update AppExecutionCommand: " + command);
+
+ param.put(util.PropertyName.APP_EXECUTION_COMMAND, command);
+ }
+
+ private static void dbg(String message)
+ {
+ if (debug)
+ {
+ System.out.println(utils.getDateTime() + "OfficeProvider: " + message);
+ }
+
+ }
+
+ private class OfficeWatcherPing extends Thread
+ {
+
+ private final OfficeWatcher ow;
+ private boolean bStop = false;
+
+ public OfficeWatcherPing(OfficeWatcher ow)
+ {
+ this.ow = ow;
+ }
+
+ @Override
+ public void run()
+ {
+ System.out.println(utils.getDateTime() + "OfficeProvider:Owp: start ");
+
+ 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)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ }
+
+ public void finish()
+ {
+ synchronized(this)
+ {
+ bStop = true;
+ System.out.println(utils.getDateTime() + "OfficeProvider:Owp: stop ");
+
+ notify();
+ }
+ }
+ }
+
+private void deleteFilesAndDirector(File file)
+ {
+ File f = file;
+ if(f.isDirectory())
+ {
+ File files[] = f.listFiles();
+ for(int i = 0; i < files.length; i++)
+ {
+ deleteFilesAndDirector(files[i]);
+ }
+ f.delete();
+ }
+ else if (f.isFile())
+ {
+ f.delete();
+ }
+ }
+}
diff --git a/qadevOOo/runner/helper/OfficeWatcher.java b/qadevOOo/runner/helper/OfficeWatcher.java
new file mode 100644
index 000000000000..2068a7f5246c
--- /dev/null
+++ b/qadevOOo/runner/helper/OfficeWatcher.java
@@ -0,0 +1,132 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package helper;
+
+import lib.TestParameters;
+import java.util.StringTokenizer;
+import util.utils;
+
+public class OfficeWatcher extends Thread implements share.Watcher {
+
+ public boolean finish;
+ private TestParameters params;
+ private int StoredPing = 0;
+ private boolean debug = false;
+
+ /** Creates new OfficeWatcher
+ * @param param
+ */
+ public OfficeWatcher(TestParameters param) {
+ finish = false;
+ this.params = param;
+ debug = params.getBool(util.PropertyName.DEBUG_IS_ACTIVE);
+ }
+
+ /**
+ * pings the office watcher to check for changes
+ */
+ public void ping() {
+ try {
+ StoredPing++;
+ } catch (Exception e) {
+ StoredPing = 0;
+ }
+ }
+
+ /**
+ * returns the amount of pings
+ * @return returns the amount of pings
+ */
+ public int getPing() {
+ return StoredPing;
+ }
+
+ public void run() {
+ dbg("started");
+ boolean isDone = false;
+ final ProcessHandler ph = (ProcessHandler) params.get("AppProvider");
+ int timeOut = params.getInt("TimeOut");
+ if (ph == null) {
+ isDone = true;
+ }
+ while (!isDone) {
+ timeOut = params.getInt("TimeOut");
+ final int previous = StoredPing;
+ shortWait(timeOut == 0 ? 30000 : timeOut);
+ // a timeout with value 0 lets watcher not react.
+ if ((StoredPing == previous) && timeOut != 0) {
+ isDone = true;
+ }
+ // execute in case the watcher is not needed anymore
+ if (finish) {
+ return;
+ }
+ }
+ if (ph != null) {
+ dbg("the Office is idle for " + timeOut / 1000 +
+ " seconds, it probably hangs and is killed NOW.");
+ final String AppKillCommand = (String) params.get(util.PropertyName.APP_KILL_COMMAND);
+ if (AppKillCommand != null) {
+ final StringTokenizer aKillCommandToken = new StringTokenizer(AppKillCommand, ";");
+ while (aKillCommandToken.hasMoreTokens()) {
+ final String sKillCommand = aKillCommandToken.nextToken();
+
+ dbg("User defined an application to destroy the started process.");
+ dbg("Trying to execute: " + sKillCommand);
+
+ final ProcessHandler pHdl = new ProcessHandler(sKillCommand);
+ pHdl.executeSynchronously();
+// dbg("---> Output of killoffice:");
+// dbg(pHdl.getOutputText());
+// dbg("<--- Output of killoffice");
+// dbg("---> Error output of killoffice:");
+// dbg(pHdl.getErrorText());
+// dbg("<--- Error output of killoffice");
+
+ }
+ }
+ ph.kill();
+ } else {
+ dbg("reaeched timeout but ProcessHandler is NULL");
+ }
+ shortWait(timeOut == 0 ? 30000 : timeOut);
+ dbg("finished");
+ }
+
+ protected void shortWait(int timeOut) {
+ try {
+ OfficeWatcher.sleep(timeOut);
+ } catch (java.lang.InterruptedException ie) {
+ }
+ }
+
+ protected void dbg(String message) {
+ if (debug) {
+ System.out.println(utils.getDateTime() + "OfficeWatcher: " + message);
+ }
+ }
+}
diff --git a/qadevOOo/runner/helper/ParameterNotFoundException.java b/qadevOOo/runner/helper/ParameterNotFoundException.java
new file mode 100644
index 000000000000..f1ea980e1533
--- /dev/null
+++ b/qadevOOo/runner/helper/ParameterNotFoundException.java
@@ -0,0 +1,39 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package helper;
+
+/**
+ * This exception is thrown when a parameter could not be found.
+ *
+ */
+public class ParameterNotFoundException extends Exception {
+ public ParameterNotFoundException(String message){
+ super (message);
+ }
+
+}
diff --git a/qadevOOo/runner/helper/ProcessHandler.java b/qadevOOo/runner/helper/ProcessHandler.java
new file mode 100644
index 000000000000..c414accd44ac
--- /dev/null
+++ b/qadevOOo/runner/helper/ProcessHandler.java
@@ -0,0 +1,824 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package helper;
+
+import java.io.InputStream;
+import java.io.File;
+import java.io.PrintWriter;
+import java.io.PrintStream;
+import java.io.LineNumberReader;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import lib.TestParameters;
+import util.PropertyName;
+import util.utils;
+
+/**
+ * Class collect information from input stream in
+ * background (sparate thread) and outputs it to
+ * some log stream. I helps to avoid buffer overflow
+ * when output stream has small buffer size (e.g.
+ * in case when handling stdout from external
+ * <code>Process</code>)
+ *
+ * This class is currently used by ProcesHandler
+ * internally only.
+ */
+class Pump extends Thread
+{
+
+ private LineNumberReader reader;
+ private String pref;
+ private StringBuffer buf = new StringBuffer(256);
+ private PrintWriter log;
+
+ /**
+ * Creates Pump for specified <code>InputStream</code>.
+ * This Pump also synchronously output text read to
+ * log by prefixed lines. Constructor immediately
+ * starts reading in a separate thread.
+ *
+ * @param is Stream which requires permanent reading.
+ * @param log Writer where prefixed text lines to be output
+ * @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;
+ reader = new LineNumberReader(new InputStreamReader(is));
+ this.log = log;
+ start();
+ }
+
+ public void run()
+ {
+ try
+ {
+ String line = reader.readLine();
+ while (line != null)
+ {
+ log.println(pref + line);
+ log.flush();
+ buf.append(line).append('\n');
+ line = reader.readLine();
+ }
+ }
+ catch (java.io.IOException e)
+ {
+ log.println(pref + "Exception occured: " + e);
+ }
+ }
+
+ /**
+ * Returns the text collected from input stream.
+ */
+ public String getStringBuffer()
+ {
+ return buf.toString();
+ }
+}
+
+/**
+ * Class provides convenient way for running external program
+ * handle its standard streams, control execution and check results.
+ * Instance of this class must be created only for a single
+ * execution. If you need to execute the same command again you
+ * should create a new instance for this.
+ */
+public class ProcessHandler
+{
+
+ private String cmdLine;
+ private String[] cmdLineArray;
+ private String[] envVars = null;
+ private File workDir = null;
+ private PrintWriter log;
+ private int exitValue = -1;
+ private boolean isFinished = false;
+ private boolean isStarted = false;
+ private boolean mbTimedOut = false;
+ private long mTimeOut = 0;
+ private String stdInBuff = "";
+ private Pump stdout = null;
+ private Pump stderr = null;
+ private PrintStream stdIn = null;
+ private Process m_aProcess = null;
+ private TestParameters param = null;
+ private boolean debug = false;
+
+ /**
+ * Creates instance with specified external command.
+ * Debug info and output
+ * of external command is printed to stdout.
+ * @param cmdLine
+ */
+ public ProcessHandler(String cmdLine)
+ {
+ this(cmdLine, null, null, null, 0);
+ }
+
+ /**
+ * Creates instance with specified external command
+ * including parameters as an array.
+ * Debug info and output
+ * of external command is printed to stdout.
+ * @param cmdLines
+ */
+ public ProcessHandler(String[] cmdLines)
+ {
+ this(null, null, null, null, 0);
+ cmdLineArray = cmdLines;
+ }
+
+ /**
+ * Creates instance with specified external command
+ * including parameters as an array, with environment
+ * variables.
+ * Debug info and output
+ * of external command is printed to stdout.
+ * @param cmdLines
+ * @param envVars
+ * @see java.lang.Runtime exec(String[], String[])
+ */
+ public ProcessHandler(String[] cmdLines, String[] envVars)
+ {
+ this(null, null, null, envVars, 0);
+ cmdLineArray = cmdLines;
+ }
+
+ /**
+ * Creates instance with specified external command
+ * including parameters as an array, with environment
+ * variables. The command will be started in workDir.
+ * Debug info and output
+ * of external command is printed to stdout.
+ * @param cmdLines
+ * @param workDir
+ */
+ public ProcessHandler(String[] cmdLines, File workDir)
+ {
+ this(null, null, workDir, null, 0);
+ cmdLineArray = cmdLines;
+
+ }
+
+ /**
+ * Creates instance with specified external command and
+ * log stream where debug info and output
+ * of external command is printed out. The command will be started in workDir.
+ * @param cmdLines
+ * @param log
+ * @param workDir
+ */
+ public ProcessHandler(String[] cmdLines, PrintWriter log, File workDir)
+ {
+ this(null, log, workDir, null, 0);
+ cmdLineArray = cmdLines;
+ }
+
+ /**
+ * Creates instance with specified external command and
+ * log stream where debug info and output
+ * of external command is printed out.
+ * @param cmdLine
+ * @param log
+ */
+ public ProcessHandler(String cmdLine, PrintWriter log)
+ {
+ this(cmdLine, log, null, null, 0);
+ }
+
+ /**
+ * Creates instance with specified external command and set the time out for the command.
+ * @param cmdLine
+ * @param timeOut
+ */
+ public ProcessHandler(String cmdLine, int timeOut)
+ {
+ this(cmdLine, null, null, null, timeOut);
+ }
+
+ /**
+ * Creates instance with specified external command which
+ * will be executed in the some work directory.
+ * Debug info and output
+ * of external commandis printed to stdout.
+ * @param cmdLine
+ * @param workDir
+ */
+ public ProcessHandler(String cmdLine, File workDir)
+ {
+ this(cmdLine, null, workDir, null, 0);
+ }
+
+ /**
+ * Creates instance with specified external command which
+ * will be executed in the some work directory.
+ * Debug info and output printed in log stream.
+ * @param cmdLine
+ * @param log
+ * @param workDir
+ */
+ public ProcessHandler(String cmdLine, PrintWriter log, File workDir)
+ {
+ this(cmdLine, log, workDir, null, 0);
+ }
+
+ /**
+ * Creates instance with specified external command which
+ * will be executed in the some work directory and
+ * log stream where debug info and output
+ * of external command is printed .
+ * The specified environment variables are set for the new process.
+ * If log stream is null, logging is printed to stdout.
+ * @param cmdLine
+ * @param log
+ * @param workDir
+ * @param envVars
+ */
+ public ProcessHandler(String cmdLine, PrintWriter log, File workDir, String[] envVars)
+ {
+ this(cmdLine, log, workDir, envVars, 0);
+ }
+
+ /**
+ * Creates instance with specified external command which
+ * will be executed in the some work directory and
+ *
+ * @param cmdLine the command to be executed
+ * @param log log stream where debug info and output
+ * of external command is printed .
+ * @param workDir The working directory of the new process
+ * @param envVars The specified environment variables are
+ * set for the new process.
+ * If log stream is null, logging is printed to stdout.
+ * @param timeOut When started sychronisly, the maximum time the
+ * process will live. When the process being destroyed
+ * a log will be written out. It can be asked on
+ * <code>isTimedOut()</code> if it has been terminated.
+ *
+ * timeOut > 0
+ * Waits specified time in miliSeconds for
+ * process to exit and return its status.
+ *
+ * timeOut = 0
+ * Waits for the process to end regulary
+ *
+ * timeOut < 0
+ * Kills the process immediately
+ *
+ *
+ */
+ 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)
+ {
+ this.log = new PrintWriter(new OutputStreamWriter(System.out));
+ }
+ else
+ {
+ this.log = log;
+ }
+ this.mTimeOut = timeOut;
+ }
+
+ /**
+ * Creates instance with specified external command which
+ * will be executed in the some work directory and
+ * log stream where debug info and output of external command is printed.
+ * If log stream is null, logging is printed to stdout.
+ * From the <CODE>TestParameters</CODE> the <CODE>OfficeWachter</CODE> get a ping.
+ * @param commands
+ * @param log
+ * @param workDir
+ * @param shortWait If this parameter is ture the <CODE>mTimeOut</CODE> is set to 5000 ms, else it is set to
+ * half of time out from parameter timeout.
+ * @param param the TestParameters
+ * @see lib.TestParameters
+ * @see helper.OfficeWatcher
+ */
+ 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)
+ {
+ this.mTimeOut = shortWait;
+ }
+ else
+ {
+ this.mTimeOut = (long) (param.getInt(PropertyName.TIME_OUT) / 1.3);
+ }
+ debug = param.getBool(PropertyName.DEBUG_IS_ACTIVE);
+
+ }
+
+ /**
+ * 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
+ */
+ public void runCommand()
+ {
+
+ boolean changedText = true;
+ int count = 0;
+ String memText = "";
+
+ this.executeAsynchronously();
+
+ OfficeWatcher ow = null;
+ if (param != null)
+ {
+ ow = (OfficeWatcher) param.get(PropertyName.OFFICE_WATCHER);
+ }
+ if (ow != null)
+ {
+ ow.ping();
+ }
+
+ int hangcheck = 10;
+ while (!this.isFinished() && changedText)
+ {
+ count++;
+ // dbg("runCommand: waiting " + mTimeOut / 1000 + " seconds while command execution is ongoing... " + count);
+ // shortWait(mTimeOut);
+ // shortWait(2000); // wait 2 seconds.
+ //waitFor(mTimeOut);
+ waitFor(2000, false); // wait but don't kill
+
+ if (ow != null)
+ {
+ ow.ping();
+ }
+ // check for changes in the output stream. If there are no changes, the process maybe hangs
+ if (!this.isFinished())
+ {
+ hangcheck--;
+ if (hangcheck < 0)
+ {
+ String sOutputText = getOutputText();
+ if (sOutputText.length() == memText.length())
+ {
+ changedText = false;
+ // dbg("runCommand Could not detect changes in output stream!!!");
+ }
+ hangcheck = 10;
+ memText = this.getOutputText();
+ }
+ }
+ }
+
+ if (!this.isFinished())
+ {
+ dbg("runCommand Process ist not finished but there are no changes in output stream.");
+ this.kill();
+ }
+ }
+
+ public boolean isTimedOut()
+ {
+ return mbTimedOut;
+ }
+
+ private void setTimedOut(boolean bTimedOut)
+ {
+ mbTimedOut = bTimedOut;
+ }
+
+ /**
+ * Executes the command and returns only when the process
+ * exits.
+ *
+ * @return <code>true</code> if process was successfully
+ * started and correcly exits (exit code doesn't affect
+ * to this result).
+ */
+ public boolean executeSynchronously()
+ {
+ execute();
+ return waitFor(mTimeOut);
+ }
+
+ /**
+ * Executes the command immediately returns. The process
+ * remains in running state. Control of its state should
+ * be made by <code>waitFor</code> methods.
+ *
+ * @return <code>true</code> if process was successfully
+ * started.
+ */
+ public boolean executeAsynchronously()
+ {
+ execute();
+ return isStarted();
+ }
+
+ public synchronized void kill()
+ {
+ if (!isStarted())
+ {
+ return;
+ }
+ boolean exit = false;
+ int counter = 1;
+ while (counter < 3 && !exit)
+ {
+ m_aProcess.destroy();
+
+ try
+ {
+ Thread.sleep(1000 * counter); // 5000
+ }
+ catch (java.lang.InterruptedException e)
+ {
+ }
+ try
+ {
+ final int exit_Value = m_aProcess.exitValue();
+ if (exit_Value < 1)
+ {
+ exit = true;
+ }
+ else
+ {
+ counter++;
+ }
+ dbg("kill: process closed with exit code " + exit_Value);
+ }
+ catch (java.lang.IllegalThreadStateException e)
+ {
+ if (counter < 3)
+ {
+ dbg("kill: Couldn't close process after " + counter + " attempts, trying again");
+ }
+ counter++;
+ }
+ }
+ isStarted = false;
+ }
+
+ /**
+ * Returns the time in seconds since 1st January 1970
+ * @return
+ */
+ public static long getSystemTime()
+ {
+ // Calendar cal = new GregorianCalendar();
+ // final long nTime = cal.getTimeInMillis();
+ final long nTime = System.currentTimeMillis();
+ return nTime;
+ }
+ private long m_nExactStartTimeInMillisec;
+
+ private void initialExactStartTime()
+ {
+ m_nExactStartTimeInMillisec = getSystemTime();
+ }
+
+ public long getProcessStartTime()
+ {
+ return m_nExactStartTimeInMillisec;
+ }
+
+ protected void execute()
+ {
+ if (isStarted())
+ {
+ throw new RuntimeException(
+ "The process handler has already been executed.");
+ }
+ final Runtime runtime = Runtime.getRuntime();
+ try
+ {
+ if (cmdLine == null)
+ {
+ log.print(utils.getDateTime() + "execute: Starting command from array: ");
+ for (int i = 0; i < cmdLineArray.length; i++)
+ {
+ log.print(cmdLineArray[i]);
+ log.print(" ");
+ }
+ log.println("");
+ initialExactStartTime();
+ m_aProcess = runtime.exec(cmdLineArray, envVars);
+ }
+ else
+ {
+ if (workDir != null)
+ {
+ log.println(utils.getDateTime() + "execute: Starting command: " + cmdLine + " " +
+ workDir.getAbsolutePath());
+ m_aProcess = runtime.exec(cmdLine, envVars, workDir);
+ }
+ else
+ {
+ log.println(utils.getDateTime() + "execute: Starting command: " + cmdLine);
+ m_aProcess = runtime.exec(cmdLine, envVars);
+ }
+ }
+ isStarted = true;
+ }
+ catch (java.io.IOException e)
+ {
+ if (cmdLine == null)
+ {
+ log.println(utils.getDateTime() + "execute: The command array can't be started: " + e);
+ }
+ else
+ {
+ log.println(utils.getDateTime() + "execute: The command " + cmdLine + " can't be started: " + e);
+ }
+ return;
+ }
+ dbg("execute: pump io-streams");
+ 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");
+
+ flushInput();
+ }
+
+ /**
+ * This method is useful when the process was executed
+ * asynchronously. Waits for process to exit and return
+ * its result.
+ *
+ * @return <code>true</code> if process correctly exited
+ * (exit code doesn't affect to this result).
+ */
+ public boolean waitFor()
+ {
+ return waitFor(0);
+ }
+
+ /**
+ * This method is useful when the process was executed
+ * asynchronously. Waits during specified time for process
+ * to exit and return its status.
+ *
+ * @param timeout > 0
+ * Waits specified time in miliSeconds for
+ * process to exit and return its status.
+ *
+ * = 0
+ * Waits for the process to end regulary
+ *
+ * < 0
+ * Kills the process immediately
+ *
+ * @return <code>true</code> if process correctly exited
+ * (exit code doesn't affect to this result).
+ */
+ public boolean waitFor(long timeout)
+ {
+ return waitFor(timeout, true);
+ }
+
+ private boolean waitFor(long timeout, boolean bKillProcessAfterTimeout)
+ {
+ if (isFinished())
+ {
+ return true;
+ }
+ if (!isStarted())
+ {
+ return false;
+ }
+
+ if (timeout == 0)
+ {
+ try
+ {
+ m_aProcess.waitFor();
+ }
+ catch (InterruptedException e)
+ {
+ log.println("The process was interrupted: " + e);
+ }
+ isFinished = true;
+ try
+ {
+ exitValue = m_aProcess.exitValue();
+ }
+ catch (IllegalThreadStateException e)
+ {
+ }
+ }
+ else
+ {
+ try
+ {
+ while (!isFinished && timeout > 0)
+ {
+ isFinished = true;
+ Thread.sleep(1000);
+ timeout -= 1000;
+ try
+ {
+ exitValue = m_aProcess.exitValue(); // throws exception if not finished
+ }
+ catch (IllegalThreadStateException e)
+ {
+ isFinished = false;
+ }
+ }
+ if (timeout < 0)
+ {
+ setTimedOut(true);
+ log.println("The process has timed out!");
+ }
+ }
+ catch (InterruptedException ex)
+ {
+ log.println("The process was interrupted: " + ex);
+ }
+ }
+
+ if (bKillProcessAfterTimeout == true)
+ {
+ if (!isFinished)
+ {
+ log.println("Going to destroy the process!!");
+ m_aProcess.destroy();
+ log.println("Process has been destroyed!");
+ }
+ }
+// Removed as hung up in SDK test 'PathSettings'
+// try {
+// stdout.join();
+// stderr.join();
+// } catch (InterruptedException e) {}
+
+ return isFinished();
+ }
+
+ protected void flushInput()
+ {
+ if (stdIn == null)
+ {
+ return;
+ }
+
+ synchronized(stdInBuff)
+ {
+ stdIn.print(stdInBuff);
+ stdIn.flush();
+ stdInBuff = "";
+ }
+ }
+
+ /**
+ * Returns the text output by external command to stdout.
+ * @return the text output by external command to stdout
+ */
+ public String getOutputText()
+ {
+ if (stdout == null)
+ {
+ return "";
+ }
+ else
+ {
+ return stdout.getStringBuffer();
+ }
+ }
+
+ /**
+ * Returns the text output by external command to stderr.
+ * @return the text output by external command to stderr
+ */
+ public String getErrorText()
+ {
+ if (stderr == null)
+ {
+ return "";
+ }
+ else
+ {
+ return stderr.getStringBuffer();
+ }
+ }
+
+ /**
+ * Prints the string specified to sdtin of external
+ * command. '\n' is not added so if you need you
+ * should terminate the string with '\n'. <p>
+ *
+ * The method can also be called before the command
+ * starts its execution. Then the text is buffered
+ * and transfered to command when it will be started.
+ * @param str
+ */
+ public void printInputText(String str)
+ {
+ stdInBuff += str;
+ flushInput();
+ }
+
+ /**
+ * Returns information about was the command started or
+ * not.
+ *
+ * @return <code>true</code> if the external command was
+ * found and successfully started.
+ */
+ public boolean isStarted()
+ {
+ return isStarted;
+ }
+
+ /**
+ * Returns the information about the final state of command
+ * execution.
+ *
+ * @return <code>true</code> if the command correctly starts,
+ * exits and was not interrupted due to timeout.
+ */
+ public boolean isFinished()
+ {
+ return isFinished;
+ }
+
+ /**
+ * Returns exit code of the external command.
+ *
+ * @return exit code of command if it was finished,
+ * -1 if not.
+ */
+ public int getExitCode()
+ {
+ try
+ {
+ exitValue = m_aProcess.exitValue();
+ }
+ catch (Exception e)
+ {
+ //System.out.println("No ExitValue available");
+ }
+
+ return exitValue;
+ }
+
+ /** Causes the thread to sleep some time.
+ * @param milliseconds
+ */
+ public static void shortWait(long milliseconds)
+ {
+ try
+ {
+ Thread.sleep(milliseconds);
+ }
+ catch (InterruptedException e)
+ {
+ System.out.println("While waiting :" + e);
+ }
+ }
+
+ private void dbg(String message)
+ {
+ if (debug)
+ {
+ log.println(utils.getDateTime() + "PH." + message);
+ }
+ }
+}
diff --git a/qadevOOo/runner/helper/PropertyHandlerFactroy.java b/qadevOOo/runner/helper/PropertyHandlerFactroy.java
new file mode 100644
index 000000000000..1dcdd3d3b2b3
--- /dev/null
+++ b/qadevOOo/runner/helper/PropertyHandlerFactroy.java
@@ -0,0 +1,49 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************
+ */
+
+package helper;
+
+import com.sun.star.lang.XSingleComponentFactory;
+
+public class PropertyHandlerFactroy implements XSingleComponentFactory{
+
+ /** Creates a new instance of PropertyHandlerFactroy */
+ public PropertyHandlerFactroy() {
+ }
+
+ public Object createInstanceWithArgumentsAndContext(Object[] obj, com.sun.star.uno.XComponentContext xComponentContext)
+ throws com.sun.star.uno.Exception {
+ return new PropertyHandlerImpl();
+ }
+
+ public Object createInstanceWithContext(com.sun.star.uno.XComponentContext xComponentContext)
+ throws com.sun.star.uno.Exception {
+ return new PropertyHandlerImpl();
+ }
+
+}
diff --git a/qadevOOo/runner/helper/PropertyHandlerImpl.java b/qadevOOo/runner/helper/PropertyHandlerImpl.java
new file mode 100644
index 000000000000..01ab88e05e6b
--- /dev/null
+++ b/qadevOOo/runner/helper/PropertyHandlerImpl.java
@@ -0,0 +1,258 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package helper;
+
+import com.sun.star.beans.UnknownPropertyException;
+import com.sun.star.inspection.LineDescriptor;
+import com.sun.star.inspection.XPropertyControlFactory;
+import com.sun.star.inspection.XPropertyHandler;
+
+/**
+ * This implementation of <CODE>PropertyHandler</CODE> do currently nothig.
+ * All methods are implemented, but not filled with content.
+ * @see com.sun.star.inspection.XPropertyHandler
+ */
+public class PropertyHandlerImpl implements XPropertyHandler{
+
+ /** Creates a new instance of PropertyHandlerImpl */
+ public PropertyHandlerImpl() {
+ }
+
+ /**
+ * This method currently do nothig
+ * @param ActuatingPropertyName the id of the actuating property.
+ * @param NewValue the new value of the property
+ * @param OldValue the old value of the property
+ * @param InspectorUI a callback for updating the object inspector UI
+ * @param FirstTimeInit If true , the method is called for the first-time update of the respective property, that is, when the property browser is just initializing with the properties of the introspected object.
+ * If false , there was a real ::com::sun::star::beans::XPropertyChangeListener::propertyChange event which triggered the call.
+ *
+ * In some cases it may be necessary to differentiate between both situations. For instance, if you want to set the value of another property when an actuating property's value changed, you should definately not do this when FirstTimeInit is true .
+ * @throws com.sun.star.lang.NullPointerException ::com::sun::star::lang::NullPointerException if InspectorUI is NULL
+ */
+ public void actuatingPropertyChanged(
+ String ActuatingPropertyName,
+ Object NewValue,
+ Object OldValue,
+ com.sun.star.inspection.XObjectInspectorUI InspectorUI,
+ boolean FirstTimeInit)
+ throws com.sun.star.lang.NullPointerException {
+ }
+
+ /**
+ * This method currently do nothig
+ * @param xEventListener the listener to notify about changes
+ */
+ public void addEventListener(com.sun.star.lang.XEventListener xEventListener) {
+ }
+
+ /**
+ * This method currently do nothig
+ * @param xPropertyChangeListener the listener to notify about property changes
+ * @throws com.sun.star.lang.NullPointerException com::sun::star::lang::NullPointerException if the listener is NULL
+ */
+ public void addPropertyChangeListener(com.sun.star.beans.XPropertyChangeListener xPropertyChangeListener) throws com.sun.star.lang.NullPointerException {
+ }
+
+ /**
+ * This method currently do nothig
+ * @param PropertyName The name of the property whose value is to be converted.
+ * @param PropertyValue The to-be-converted property value.
+ * @param ControlValueType The target type of the conversion. This type is determined by the control which is used to display the property, which in turn is determined by the handler itself in describePropertyLine .
+ * Speaking strictly, this is passed for convenience only, since every XPropertyHandler implementation should know exactly which type to expect, since it implicitly determined this type in describePropertyLine by creating an appropriate XPropertyControl .
+ *
+ * @throws com.sun.star.beans.UnknownPropertyException ::com::sun::star::beans::UnknownPropertyException if the given property is not supported by the property handler
+ * @return null
+ */
+ public Object convertToControlValue(
+ String PropertyName,
+ Object PropertyValue,
+ com.sun.star.uno.Type ControlValueType)
+ throws com.sun.star.beans.UnknownPropertyException {
+ return null;
+ }
+
+ /**
+ * This method currently do nothig
+ * @param PropertyName The name of the conversion's target property.
+ * @param ControlValue The to-be-converted control value. This value has been obtained from an XPropertyControl , using its Value attribute.
+ * @throws com.sun.star.beans.UnknownPropertyException ::com::sun::star::beans::UnknownPropertyException if the given property is not supported by the property handler
+ * @return null
+ */
+ public Object convertToPropertyValue(String PropertyName, Object ControlValue) throws com.sun.star.beans.UnknownPropertyException {
+ return null;
+ }
+
+ /**
+ * This method currently do nothig
+ * @param PropertyName the name of the property whose user interface is to be described
+ * @param out_Descriptor the descriptor of the property line, to be filled by the XPropertyHandler implementation
+ * @param ControlFactory a factory for creating XPropertyControl instances. Must not be NULL .
+ * @throws com.sun.star.beans.UnknownPropertyException ::com::sun::star::beans::UnknownPropertyException if the given property is not supported by this handler
+ *
+ * @throws com.sun.star.lang.NullPointerException ::com::sun::star::lang::NullPointerException if ControlFactory is NULL .
+ */
+ public LineDescriptor describePropertyLine(
+ String PropertyName,
+ com.sun.star.inspection.XPropertyControlFactory ControlFactory)
+ throws com.sun.star.beans.UnknownPropertyException,
+ com.sun.star.lang.NullPointerException {
+ return null;
+ }
+
+ /**
+ * This method currently do nothig
+ */
+ public void dispose() {
+ }
+
+ /**
+ * This method currently do nothig
+ * @return null
+ */
+ public String[] getActuatingProperties() {
+ return null;
+ }
+
+ /**
+ * This method currently do nothig
+ * @param PropertyName the name of the property whose state is to be retrieved
+ * @throws com.sun.star.beans.UnknownPropertyException ::com::sun::star::beans::UnknownPropertyException if the given property is not supported by the property handler
+ * @return null
+ */
+ public com.sun.star.beans.PropertyState getPropertyState(String PropertyName)
+ throws com.sun.star.beans.UnknownPropertyException {
+ return null;
+ }
+
+ /**
+ * This method currently do nothig
+ * @param PropertyName the name of the property whose value is to be retrieved
+ * @throws com.sun.star.beans.UnknownPropertyException ::com::sun::star::beans::UnknownPropertyException if the given property is not supported by the property handler
+ * @return null
+ */
+ public Object getPropertyValue(String PropertyName) throws com.sun.star.beans.UnknownPropertyException {
+ return null;
+ }
+
+ /**
+ * This method currently do nothig
+ * @return null
+ */
+ public String[] getSupersededProperties() {
+ return null;
+ }
+
+ /**
+ * This method currently do nothig
+ * @return null
+ */
+ public com.sun.star.beans.Property[] getSupportedProperties() {
+ return null;
+ }
+
+ /**
+ * This method currently do nothig
+ * @param Component the component to inspect. Must not be NULL
+ * @throws com.sun.star.lang.NullPointerException com::sun::star::lang::NullPointerException if the component is NULL
+ */
+ public void inspect(Object Component) throws com.sun.star.lang.NullPointerException {
+ }
+
+ /**
+ * This method currently do nothig
+ * @param PropertyName the name of the property whose composability is to be determined
+ * @throws com.sun.star.beans.UnknownPropertyException ::com::sun::star::beans::UnknownPropertyException if the given property is not supported by the property handler
+ *
+ *
+ * @return null
+ */
+ public boolean isComposable(String PropertyName) throws com.sun.star.beans.UnknownPropertyException {
+ return false;
+ }
+
+ /**
+ * This method currently do nothig
+ * @param PropertyName The name of the property whose browse button has been clicked
+ * @param Primary true if and only if the primary button has been clicked, false otherwise
+ * @param out_Data If the method returns InteractiveSelectionResult::ObtainedValue , then _rData contains the value which has been interactively obtained from the user, and which still needs to be set at the inspected component.
+ * @param InspectorUI provides access to the object inspector UI. Implementations should use this if the property selection requires non-modal user input. In those cases, onInteractivePropertySelection should return InteractiveSelectionResult::Pending , and the UI for (at least) the property whose input is still pending should be disabled.
+ *
+ * @throws com.sun.star.beans.UnknownPropertyException ::com::sun::star::beans::UnknownPropertyException if the given property is not supported by the property handler
+ * @throws com.sun.star.lang.NullPointerException ::com::sun::star::lang::NullPointerException if InspectorUI is NULL
+ * @return null
+ */
+ public com.sun.star.inspection.InteractiveSelectionResult onInteractivePropertySelection(
+ String PropertyName,
+ boolean Primary,
+ Object[] out_Data,
+ com.sun.star.inspection.XObjectInspectorUI InspectorUI)
+ throws com.sun.star.beans.UnknownPropertyException,
+ com.sun.star.lang.NullPointerException {
+ return null;
+ }
+
+ /**
+ * This method currently do nothig
+ * @param xEventListener the listener to be revoked
+ */
+ public void removeEventListener(com.sun.star.lang.XEventListener xEventListener) {
+ }
+
+ /**
+ * This method currently do nothig
+ * @param xPropertyChangeListener the listener to be revoke
+ */
+ public void removePropertyChangeListener(com.sun.star.beans.XPropertyChangeListener xPropertyChangeListener) {
+ }
+
+ /**
+ * This method currently do nothig
+ * @param PropertyName the name of the property whose value is to be set
+ * @param Value the property value to set
+ * @throws com.sun.star.beans.UnknownPropertyException ::com::sun::star::beans::UnknownPropertyException if the given property is not supported by the property handler
+ */
+ public void setPropertyValue(String PropertyName, Object Value) throws com.sun.star.beans.UnknownPropertyException {
+ }
+
+ /**
+ * This method currently do nothig
+ * @param Suspend Whether the handler is to be suspended true or reactivated ( false ). The latter happens if a handler was successfully suspended, but an external instance vetoed the whole suspension process.
+ * @return false
+ */
+ public boolean suspend(boolean Suspend) {
+ return false;
+ }
+
+ /**
+ * This method currently do nothig
+ */
+
+ public void describePropertyLine(String string, LineDescriptor[] lineDescriptor, XPropertyControlFactory xPropertyControlFactory) throws UnknownPropertyException, com.sun.star.lang.NullPointerException {
+ }
+
+}
diff --git a/qadevOOo/runner/helper/PropertyHelper.java b/qadevOOo/runner/helper/PropertyHelper.java
new file mode 100755
index 000000000000..1b2bdbb9f175
--- /dev/null
+++ b/qadevOOo/runner/helper/PropertyHelper.java
@@ -0,0 +1,81 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package helper;
+
+import java.util.ArrayList;
+
+import com.sun.star.beans.PropertyValue;
+
+public class PropertyHelper
+{
+ /**
+ Create a PropertyValue[] from a ArrayList
+ @param _aArrayList
+ @return a PropertyValue[]
+ */
+ public static PropertyValue[] createPropertyValueArrayFormArrayList(ArrayList _aPropertyList)
+ {
+ // copy the whole PropertyValue List to an PropertyValue Array
+ PropertyValue[] aSaveProperties = null;
+
+ if (_aPropertyList == null)
+ {
+ aSaveProperties = new PropertyValue[0];
+ }
+ else
+ {
+ aSaveProperties = (PropertyValue[])_aPropertyList.toArray(new PropertyValue[_aPropertyList.size()]);
+ // old java 1.4
+// if (_aPropertyList.size() > 0)
+// {
+// aSaveProperties = new PropertyValue[_aPropertyList.size()];
+// for (int i = 0;i<_aPropertyList.size(); i++)
+// {
+// aSaveProperties[i] = (PropertyValue) _aPropertyList.get(i);
+// }
+// }
+// else
+// {
+// aSaveProperties = new PropertyValue[0];
+// }
+
+// show properties?
+// if (_aPropertyList.size() > 0)
+// {
+// // aSaveProperties = new PropertyValue[_aPropertyList.size()];
+// for (int i = 0;i<_aPropertyList.size(); i++)
+// {
+// PropertyValue aProp = (PropertyValue) _aPropertyList.get(i);
+// showProperty(aProp);
+// }
+// }
+
+ }
+ return aSaveProperties;
+ }
+}
diff --git a/qadevOOo/runner/helper/SimpleMailSender.java b/qadevOOo/runner/helper/SimpleMailSender.java
new file mode 100644
index 000000000000..221de9a75027
--- /dev/null
+++ b/qadevOOo/runner/helper/SimpleMailSender.java
@@ -0,0 +1,171 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package helper;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+
+import java.net.InetAddress;
+import java.net.Socket;
+import java.net.UnknownHostException;
+
+
+public class SimpleMailSender {
+ private String m_MailServer = "unknown";
+ private String m_Sender = "unknown";
+ private String m_Recipient = "unknown";
+ private String m_Subject = "unknown";
+ private String m_Message = "unknown";
+
+
+ public String getMailServer() {
+ return m_MailServer;
+ }
+
+ public void setMailServer(String server) {
+ m_MailServer = server;
+ }
+
+ public String getSender() {
+ return m_Sender;
+ }
+
+ public void setSender(String sender) {
+ m_Sender = sender;
+ }
+
+ public String getRecipient() {
+ return m_Recipient;
+ }
+
+ public void setRecipient(String recipient) {
+ m_Recipient = recipient;
+ }
+
+ public String getSubject() {
+ return m_Subject;
+ }
+
+ public void setSubject(String subject) {
+ m_Subject = subject;
+ }
+
+ public String getMessage() {
+ return m_Message;
+ }
+
+ public void setMessage(String msg) {
+ m_Message = msg;
+ }
+
+ public void sendMail() {
+ if (m_MailServer.equals ("unknown")) {
+ System.out.println("No Mailserver given ... exiting");
+ return;
+ }
+ if (m_Recipient.equals ("unknown")) {
+ System.out.println("No Recipient given ... exiting");
+ return;
+ }
+ sendMail(m_MailServer,m_Sender,m_Recipient,m_Subject,m_Message);
+ }
+
+ public void sendMail(String server, String sender,
+ String recipient, String subject, String msg) {
+ //setting member variables for reuse
+ m_MailServer = server;
+ m_Sender = sender;
+ m_Recipient = recipient;
+ m_Subject = subject;
+ m_Message = msg;
+
+ try {
+ Socket socket = new Socket(m_MailServer, 25);
+ BufferedReader input =
+ new BufferedReader(new InputStreamReader(
+ socket.getInputStream(), "8859_1"));
+ BufferedWriter output =
+ new BufferedWriter(new OutputStreamWriter(
+ socket.getOutputStream(), "8859_1"));
+
+ sendline(input, output, "HELO " + getHostName());
+ sendline(input, output, "MAIL FROM: " + m_Sender);
+ sendline(input, output, "RCPT TO: <" + m_Recipient + ">");
+ sendline(input, output, "DATA");
+ sendline(output, "MIME-Version: 1.0");
+ sendline(output, "Subject: " + m_Subject);
+ sendline(output, "From: " + m_Sender);
+ sendline(output, "To: " + m_Recipient);
+ sendline(output,
+ "Content-Type: text/html; charset=\"us-ascii\"\r\n");
+
+ // Send the body
+ sendline(output, m_Message);
+
+ sendline(input, output, ".");
+ sendline(input, output, "QUIT");
+ socket.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ private void sendline(BufferedReader input,
+ BufferedWriter output, String line) {
+ try {
+ output.write(line + "\r\n");
+ output.flush();
+ line = input.readLine();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ private void sendline(BufferedWriter output, String line) {
+ try {
+ output.write(line + "\r\n");
+ output.flush();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ private String getHostName() {
+ String hostname = "";
+
+ try {
+ InetAddress addr = InetAddress.getLocalHost();
+
+ hostname = addr.getHostName();
+ } catch (UnknownHostException e) {
+ }
+
+ return hostname;
+ }
+}
diff --git a/qadevOOo/runner/helper/StreamSimulator.java b/qadevOOo/runner/helper/StreamSimulator.java
new file mode 100644
index 000000000000..5e6554943e41
--- /dev/null
+++ b/qadevOOo/runner/helper/StreamSimulator.java
@@ -0,0 +1,533 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package helper;
+
+import com.sun.star.uno.UnoRuntime;
+
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.ucb.XSimpleFileAccess;
+
+/**
+ * It simulates an input and output stream and
+ * implements the interfaces XInputStream, XOutputStream.
+ * So it can be used for testing loading/saving of documents
+ * using streams instead of URLs.
+ *
+ */
+public class StreamSimulator implements com.sun.star.io.XInputStream ,
+ com.sun.star.io.XOutputStream ,
+ com.sun.star.io.XSeekable
+{
+ //_________________________________
+ /**
+ * @member m_sFileName name of the corrsponding file on disk
+ * @member m_xInStream the internal input stream for reading
+ * @member m_xOutStream the internal input stream for writing
+ * @member m_xSeek points at runtime to m_xInStream or m_xOutStream and make it seekable
+ *
+ * @member //m_aProtocol the external set protocol object for logging messages
+ * @member m_bInWasUsed indicates, that the input stream interface was used
+ * @member m_bOutWasUsed indicates, that the output stream interface was used
+ */
+
+ private String m_sFileName ;
+ private com.sun.star.io.XInputStream m_xInStream ;
+ private com.sun.star.io.XOutputStream m_xOutStream ;
+ private com.sun.star.io.XSeekable m_xSeek ;
+
+ //public ComplexTestEnvironment //m_aProtocol ;
+ public boolean m_bInWasUsed ;
+ public boolean m_bOutWasUsed ;
+
+ //_________________________________
+ /**
+ * construct a new instance of this class
+ * It set the name of the correspojnding file on disk, which
+ * should be source or target for the following operations on
+ * this object. And it regulate if it should function as
+ * input or output stream.
+ *
+ * @param sFileName
+ * name of the file on disk
+ * Will be used as source (if param bInput==true)
+ * or as target (if param bInput==false).
+ *
+ * @param bInput
+ * it specify, which interface should work at this object.
+ * <TRUE/> => we simulate an input stream
+ * <FALSE/> => we simulate an output stream
+ *
+ * @throw com.sun.star.io.NotConnectedException
+ * in case the internal streams to the file on disk couldn't established.
+ * They are neccessary. Otherwhise this simulator can't realy work.
+ */
+ public StreamSimulator( String sFileName , boolean bInput ,
+ lib.TestParameters param ) throws com.sun.star.io.NotConnectedException
+ {
+ ////m_aProtocol = new ComplexTestEnvironment();
+ m_sFileName = sFileName ;
+ m_bInWasUsed = false ;
+ m_bOutWasUsed = false ;
+
+ try
+ {
+ XSimpleFileAccess xHelper = (XSimpleFileAccess)
+ UnoRuntime.queryInterface(XSimpleFileAccess.class,
+ ((XMultiServiceFactory)param.getMSF()).createInstance("com.sun.star.ucb.SimpleFileAccess"));
+/* com.sun.star.ucb.XSimpleFileAccess xHelper = (com.sun.star.ucb.XSimpleFileAccess)OfficeConnect.createRemoteInstance(
+ com.sun.star.ucb.XSimpleFileAccess.class,
+ "com.sun.star.ucb.SimpleFileAccess");*/
+
+ if (xHelper == null)
+ throw new com.sun.star.io.NotConnectedException("ucb helper not available. Can't create streams.");
+
+ if (bInput)
+ {
+ m_xInStream = xHelper.openFileRead(m_sFileName);
+ m_xSeek = (com.sun.star.io.XSeekable)UnoRuntime.queryInterface(
+ com.sun.star.io.XSeekable.class,
+ m_xInStream);
+ }
+ else
+ {
+ m_xOutStream = xHelper.openFileWrite(m_sFileName);
+ m_xSeek = (com.sun.star.io.XSeekable)UnoRuntime.queryInterface(
+ com.sun.star.io.XSeekable.class,
+ m_xOutStream);
+ }
+ }
+ catch(com.sun.star.uno.Exception exUno)
+ {
+ ////m_aProtocol.log("\tstream not open. throw NotConnectedException\n\n\tfailed\n}\n");
+ throw new com.sun.star.io.NotConnectedException("Could not open the file.");
+ }
+ }
+
+/* public void finalize()
+ {
+ ////m_aProtocol.log("finalize was called. Please check if it was right or not.\n");
+ } */
+
+ //_________________________________
+ /**
+ * following methods simulates the XInputStream.
+ * The notice all actions inside the internal protocol
+ * and try to map all neccessary functions to the internal
+ * open in-stream.
+ */
+ public int readBytes( /*OUT*/ byte[][] lData ,
+ /*IN*/ int nBytesToRead ) throws com.sun.star.io.NotConnectedException ,
+ com.sun.star.io.BufferSizeExceededException,
+ com.sun.star.io.IOException
+ {
+ //m_aProtocol.log("readBytes(lData["+lData.length+"]["+lData[0]+"],"+nBytesToRead+")\n{\n");
+ m_bInWasUsed = true;
+
+ if (m_xInStream == null)
+ {
+ //m_aProtocol.log("\tstream not open. throw NotConnectedException\n\n\tfailed\n}\n");
+ throw new com.sun.star.io.NotConnectedException("stream not open");
+ }
+
+ int nRead = 0;
+ try
+ {
+ nRead = m_xInStream.readBytes(lData,nBytesToRead);
+ }
+ catch (com.sun.star.io.NotConnectedException exConnect) { //m_aProtocol.log("\tgot NotConnectedException\n\tfailed\n}\n" ); throw exConnect;
+ }
+ catch (com.sun.star.io.BufferSizeExceededException exBuffer ) { //m_aProtocol.log("\tgot BufferSizeExceededException\n\tfailed\n}\n"); throw exBuffer;
+ }
+ catch (com.sun.star.io.IOException exIO ) { //m_aProtocol.log("\tgot IOException\n\tfailed\n}\n" ); throw exIO;
+ }
+ catch (com.sun.star.uno.RuntimeException exRuntime) { //m_aProtocol.log("\tgot RuntimeException\n\tfailed\n}\n" ); throw exRuntime;
+ }
+ catch (com.sun.star.uno.Exception exUno ) { //m_aProtocol.log("\tgot Exception\n\tfailed\n}\n" );
+ }
+
+ //m_aProtocol.log("\treads "+nRead+" bytes\n\tOK\n}\n");
+
+ //if (nRead != nBytesToRead)
+ //m_aProtocol.log("there are some missing bytes for reading!\n");
+
+ return nRead;
+ }
+
+ //_________________________________
+
+ public int readSomeBytes( /*OUT*/ byte[][] lData ,
+ /*IN*/ int nMaxBytesToRead ) throws com.sun.star.io.NotConnectedException ,
+ com.sun.star.io.BufferSizeExceededException ,
+ com.sun.star.io.IOException
+ {
+ //m_aProtocol.log("readSomeBytes(lData["+lData.length+"]["+lData[0]+"],"+nMaxBytesToRead+")\n{\n");
+ m_bInWasUsed = true;
+
+ if (m_xInStream == null)
+ {
+ //m_aProtocol.log("\tstream not open. throw NotConnectedException\n\tfailed\n}\n");
+ throw new com.sun.star.io.NotConnectedException("stream not open");
+ }
+
+ int nRead = 0;
+ try
+ {
+ nRead = m_xInStream.readSomeBytes(lData,nMaxBytesToRead);
+ }
+ catch (com.sun.star.io.NotConnectedException exConnect) { //m_aProtocol.log("\tgot NotConnectedException\n\tfailed\n}\n" ); throw exConnect;
+ }
+ catch (com.sun.star.io.BufferSizeExceededException exBuffer ) { //m_aProtocol.log("\tgot BufferSizeExceededException\n\tfailed\n}\n"); throw exBuffer;
+ }
+ catch (com.sun.star.io.IOException exIO ) { //m_aProtocol.log("\tgot IOException\n\tfailed\n}\n" ); throw exIO;
+ }
+ catch (com.sun.star.uno.RuntimeException exRuntime) { //m_aProtocol.log("\tgot RuntimeException\n\tfailed\n}\n" ); throw exRuntime;
+ }
+ catch (com.sun.star.uno.Exception exUno ) { //m_aProtocol.log("\tgot Exception\n\tfailed\n}\n" );
+ }
+
+ //m_aProtocol.log("\treads "+nRead+" bytes\n\tOK\n}\n");
+
+ //if (nRead != nMaxBytesToRead)
+ //m_aProtocol.log("there are some missing bytes for reading!");
+
+ return nRead;
+ }
+
+ //_________________________________
+
+ public void skipBytes( /*IN*/ int nBytesToSkip ) throws com.sun.star.io.NotConnectedException ,
+ com.sun.star.io.BufferSizeExceededException ,
+ com.sun.star.io.IOException
+ {
+ //m_aProtocol.log("skipBytes("+nBytesToSkip+")\n{\n");
+ m_bInWasUsed = true;
+
+ if (m_xInStream == null)
+ {
+ //m_aProtocol.log("\tstream not open. throw NotConnectedException\n\tfailed\n}\n");
+ throw new com.sun.star.io.NotConnectedException("stream not open");
+ }
+
+ try
+ {
+ m_xInStream.skipBytes(nBytesToSkip);
+ }
+ catch (com.sun.star.io.NotConnectedException exConnect) { //m_aProtocol.log("\tgot NotConnectedException\n\tfailed\n}\n" ); throw exConnect;
+ }
+ catch (com.sun.star.io.BufferSizeExceededException exBuffer ) { //m_aProtocol.log("\tgot BufferSizeExceededException\n\tfailed\n}\n"); throw exBuffer;
+ }
+ catch (com.sun.star.io.IOException exIO ) { //m_aProtocol.log("\tgot IOException\n\tfailed\n}\n" ); throw exIO;
+ }
+ catch (com.sun.star.uno.RuntimeException exRuntime) { //m_aProtocol.log("\tgot RuntimeException\n\tfailed\n}\n" ); throw exRuntime;
+ }
+ catch (com.sun.star.uno.Exception exUno ) { //m_aProtocol.log("\tgot Exception\n\tfailed\n}\n" );
+ }
+
+ //m_aProtocol.log("\tOK\n}\n");
+ }
+
+ //_________________________________
+
+ public int available() throws com.sun.star.io.NotConnectedException,
+ com.sun.star.io.IOException
+ {
+ //m_aProtocol.log("available()\n{\n");
+ m_bInWasUsed = true;
+
+ if (m_xInStream == null)
+ {
+ //m_aProtocol.log("\tstream not open. throw NotConnectedException\n\tfailed\n}\n");
+ throw new com.sun.star.io.NotConnectedException("stream not open");
+ }
+
+ int nAvailable = 0;
+ try
+ {
+ nAvailable = m_xInStream.available();
+ }
+ catch (com.sun.star.io.NotConnectedException exConnect) { //m_aProtocol.log("\tgot NotConnectedException\n\tfailed\n}\n"); throw exConnect;
+ }
+ catch (com.sun.star.io.IOException exIO ) { //m_aProtocol.log("\tgot IOException\n\tfailed\n}\n" ); throw exIO;
+ }
+ catch (com.sun.star.uno.RuntimeException exRuntime) { //m_aProtocol.log("\tgot RuntimeException\n\tfailed\n}\n" ); throw exRuntime;
+ }
+ catch (com.sun.star.uno.Exception exUno ) { //m_aProtocol.log("\tgot Exception\n\tfailed\n}\n" );
+ }
+
+ //m_aProtocol.log("\treturns "+nAvailable+" bytes\n\tOK\n}\n");
+ return nAvailable;
+ }
+
+ //_________________________________
+
+ public void closeInput() throws com.sun.star.io.NotConnectedException,
+ com.sun.star.io.IOException
+ {
+ //m_aProtocol.log("closeInput()\n{\n");
+ m_bInWasUsed = true;
+
+ if (m_xInStream == null)
+ {
+ //m_aProtocol.log("\tstream not open. throw NotConnectedException\n\tfailed\n}\n");
+ throw new com.sun.star.io.NotConnectedException("stream not open");
+ }
+
+ try
+ {
+ m_xInStream.closeInput();
+ }
+ catch (com.sun.star.io.NotConnectedException exConnect) { //m_aProtocol.log("\tgot NotConnectedException\n\tfailed\n}\n"); throw exConnect;
+ }
+ catch (com.sun.star.io.IOException exIO ) { //m_aProtocol.log("\tgot IOException\n\tfailed\n}\n" ); throw exIO;
+ }
+ catch (com.sun.star.uno.RuntimeException exRuntime) { //m_aProtocol.log("\tgot RuntimeException\n\tfailed\n}\n" ); throw exRuntime;
+ }
+ catch (com.sun.star.uno.Exception exUno ) { //m_aProtocol.log("\tgot Exception\n\tfailed\n}\n" );
+ }
+
+ //m_aProtocol.log("\tOK\n}\n");
+ }
+
+ //_________________________________
+ /**
+ * following methods simulates the XOutputStream.
+ * The notice all actions inside the internal protocol
+ * and try to map all neccessary functions to the internal
+ * open out-stream.
+ */
+ public void writeBytes( /*IN*/byte[] lData ) throws com.sun.star.io.NotConnectedException ,
+ com.sun.star.io.BufferSizeExceededException ,
+ com.sun.star.io.IOException
+ {
+ //m_aProtocol.log("writeBytes(lData["+lData.length+"])\n{\n");
+ m_bOutWasUsed = true;
+
+ if (m_xOutStream == null)
+ {
+ //m_aProtocol.log("\tstream not open. throw NotConnectedException\n\tfailed\n}\n");
+ throw new com.sun.star.io.NotConnectedException("stream not open");
+ }
+
+ try
+ {
+ m_xOutStream.writeBytes(lData);
+ }
+ catch (com.sun.star.io.NotConnectedException exConnect) { //m_aProtocol.log("\tgot NotConnectedException\n\tfailed\n}\n" ); throw exConnect;
+ }
+ catch (com.sun.star.io.BufferSizeExceededException exBuffer ) { //m_aProtocol.log("\tgot BufferSizeExceededException\n\tfailed\n}\n"); throw exBuffer;
+ }
+ catch (com.sun.star.io.IOException exIO ) { //m_aProtocol.log("\tgot IOException\n\tfailed\n}\n" ); throw exIO;
+ }
+ catch (com.sun.star.uno.RuntimeException exRuntime) { //m_aProtocol.log("\tgot RuntimeException\n\tfailed\n}\n" ); throw exRuntime;
+ }
+ catch (com.sun.star.uno.Exception exUno ) { //m_aProtocol.log("\tgot Exception\n\tfailed\n}\n" );
+ }
+
+ //m_aProtocol.log("\tOK\n}\n");
+ }
+
+ //_________________________________
+
+ public void flush() throws com.sun.star.io.NotConnectedException ,
+ com.sun.star.io.BufferSizeExceededException ,
+ com.sun.star.io.IOException
+ {
+ //m_aProtocol.log("flush()\n{\n");
+ m_bOutWasUsed = true;
+
+ if (m_xOutStream == null)
+ {
+ //m_aProtocol.log("\tstream not open. throw NotConnectedException\n\tfailed\n}\n");
+ throw new com.sun.star.io.NotConnectedException("stream not open");
+ }
+
+ try
+ {
+ m_xOutStream.flush();
+ }
+ catch (com.sun.star.io.NotConnectedException exConnect) { //m_aProtocol.log("\tgot NotConnectedException\n\tfailed\n}\n" ); throw exConnect;
+ }
+ catch (com.sun.star.io.BufferSizeExceededException exBuffer ) { //m_aProtocol.log("\tgot BufferSizeExceededException\n\tfailed\n}\n"); throw exBuffer;
+ }
+ catch (com.sun.star.io.IOException exIO ) { //m_aProtocol.log("\tgot IOException\n\tfailed\n}\n" ); throw exIO;
+ }
+ catch (com.sun.star.uno.RuntimeException exRuntime) { //m_aProtocol.log("\tgot RuntimeException\n\tfailed\n}\n" ); throw exRuntime;
+ }
+ catch (com.sun.star.uno.Exception exUno ) { //m_aProtocol.log("\tgot Exception\n\tfailed\n}\n" );
+ }
+ //m_aProtocol.log("\tOK\n}\n");
+ }
+
+ //_________________________________
+
+ public void closeOutput() throws com.sun.star.io.NotConnectedException ,
+ com.sun.star.io.BufferSizeExceededException,
+ com.sun.star.io.IOException
+ {
+ //m_aProtocol.log("closeOutput()\n{\n");
+ m_bOutWasUsed = true;
+
+ if (m_xOutStream == null)
+ {
+ //m_aProtocol.log("\tstream not open. throw NotConnectedException\n\tfailed\n}\n");
+ throw new com.sun.star.io.NotConnectedException("stream not open");
+ }
+
+ try
+ {
+ m_xOutStream.closeOutput();
+ }
+ catch (com.sun.star.io.NotConnectedException exConnect) { //m_aProtocol.log("\tgot NotConnectedException\n\tfailed\n}\n" ); throw exConnect;
+ }
+ catch (com.sun.star.io.BufferSizeExceededException exBuffer ) { //m_aProtocol.log("\tgot BufferSizeExceededException\n\tfailed\n}\n"); throw exBuffer;
+ }
+ catch (com.sun.star.io.IOException exIO ) { //m_aProtocol.log("\tgot IOException\n\tfailed\n}\n" ); throw exIO;
+ }
+ catch (com.sun.star.uno.RuntimeException exRuntime) { //m_aProtocol.log("\tgot RuntimeException\n\tfailed\n}\n" ); throw exRuntime;
+ }
+ catch (com.sun.star.uno.Exception exUno ) { //m_aProtocol.log("\tgot Exception\n\tfailed\n}\n" );
+ }
+
+ //m_aProtocol.log("\tOK\n}\n");
+ }
+
+ //_________________________________
+ /**
+ * following methods simulates the XSeekable.
+ * The notice all actions inside the internal protocol
+ * and try to map all neccessary functions to the internal
+ * open stream.
+ */
+ public void seek( /*IN*/long nLocation ) throws com.sun.star.lang.IllegalArgumentException,
+ com.sun.star.io.IOException
+ {
+ //m_aProtocol.log("seek("+nLocation+")\n{\n");
+
+ if (m_xInStream != null)
+ m_bInWasUsed = true;
+ else
+ if (m_xOutStream != null)
+ m_bOutWasUsed = true;
+ else
+ //m_aProtocol.log("\tno stream open!\n");
+
+ if (m_xSeek == null)
+ {
+ //m_aProtocol.log("\tstream not seekable. throw IOException\n\tfailed\n}\n");
+ throw new com.sun.star.io.IOException("stream not seekable");
+ }
+
+ try
+ {
+ m_xSeek.seek(nLocation);
+ }
+ catch (com.sun.star.lang.IllegalArgumentException exArg ) { //m_aProtocol.log("\tgot IllegalArgumentException\n\tfailed\n}\n" ); throw exArg;
+ }
+ catch (com.sun.star.io.IOException exIO ) { //m_aProtocol.log("\tgot IOException\n\tfailed\n}\n" ); throw exIO;
+ }
+ catch (com.sun.star.uno.RuntimeException exRuntime) { //m_aProtocol.log("\tgot RuntimeException\n\tfailed\n}\n" ); throw exRuntime;
+ }
+ catch (com.sun.star.uno.Exception exUno ) { //m_aProtocol.log("\tgot Exception\n\tfailed\n}\n" );
+ }
+
+ //m_aProtocol.log("\tOK\n}\n");
+ }
+
+ //_________________________________
+
+ public long getPosition() throws com.sun.star.io.IOException
+ {
+ //m_aProtocol.log("getPosition()\n{\n");
+
+ if (m_xInStream != null)
+ m_bInWasUsed = true;
+ else
+ if (m_xOutStream != null)
+ m_bOutWasUsed = true;
+ else
+ //m_aProtocol.log("\tno stream open!\n");
+
+ if (m_xSeek == null)
+ {
+ //m_aProtocol.log("\tstream not seekable. throw IOException\n\tfailed\n}\n");
+ throw new com.sun.star.io.IOException("stream not seekable");
+ }
+
+ long nPos = 0;
+ try
+ {
+ nPos = m_xSeek.getPosition();
+ }
+ catch (com.sun.star.io.IOException exIO ) { //m_aProtocol.log("\tgot IOException\n\tfailed\n}\n" ); throw exIO;
+ }
+ catch (com.sun.star.uno.RuntimeException exRuntime) { //m_aProtocol.log("\tgot RuntimeException\n\tfailed\n}\n"); throw exRuntime;
+ }
+ catch (com.sun.star.uno.Exception exUno ) { //m_aProtocol.log("\tgot Exception\n\tfailed\n}\n" );
+ }
+
+ //m_aProtocol.log("\treturns pos="+nPos+"\n\tOK\n}\n");
+ return nPos;
+ }
+
+ //_________________________________
+
+ public long getLength() throws com.sun.star.io.IOException
+ {
+ //m_aProtocol.log("getLength()\n{\n");
+
+ if (m_xInStream != null)
+ m_bInWasUsed = true;
+ else
+ if (m_xOutStream != null)
+ m_bOutWasUsed = true;
+ else
+ //m_aProtocol.log("\tno stream open!\n");
+
+ if (m_xSeek == null)
+ {
+ //m_aProtocol.log("\tstream not seekable. throw IOException\n\tfailed\n}\n");
+ throw new com.sun.star.io.IOException("stream not seekable");
+ }
+
+ long nLen = 0;
+ try
+ {
+ nLen = m_xSeek.getLength();
+ }
+ catch (com.sun.star.io.IOException exIO ) { //m_aProtocol.log("\tgot IOException\n\tfailed\n}\n" ); throw exIO;
+ }
+ catch (com.sun.star.uno.RuntimeException exRuntime) { //m_aProtocol.log("\tgot RuntimeException\n\tfailed\n}\n"); throw exRuntime;
+ }
+ catch (com.sun.star.uno.Exception exUno ) { //m_aProtocol.log("\tgot Exception\n\tfailed\n}\n" );
+ }
+
+ //m_aProtocol.log("\treturns len="+nLen+"\n\tOK\n}\n");
+ return nLen;
+ }
+}
diff --git a/qadevOOo/runner/helper/StringHelper.java b/qadevOOo/runner/helper/StringHelper.java
new file mode 100644
index 000000000000..d2eb41606844
--- /dev/null
+++ b/qadevOOo/runner/helper/StringHelper.java
@@ -0,0 +1,125 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package helper;
+
+public class StringHelper
+{
+
+ public static String doubleQuote(String _sStr)
+ {
+ return "\"" + _sStr + "\"";
+ }
+
+ public static String singleQuote(String _sStr)
+ {
+ return "'" + _sStr + "'";
+ }
+
+ /**
+ * removes quotes if both exists at start and at end
+ */
+ public static String removeSurroundQuoteIfExists(String _sPath)
+ {
+ String sNewPath = _sPath;
+ boolean bRemoveQuotes = false;
+ if (
+ (_sPath.startsWith("\"") && _sPath.endsWith("\"")) ||
+ (_sPath.startsWith("'") && _sPath.endsWith("'"))
+ )
+ {
+ // remove trailing quotes, if exists
+ sNewPath = sNewPath.substring(1);
+
+ // remove trailing quotes, if exists
+ sNewPath = sNewPath.substring(0, sNewPath.length() - 1);
+ }
+ return sNewPath;
+ }
+
+ public static String removeQuoteIfExists(String _sPath)
+ {
+ String sNewPath = _sPath;
+
+ if (_sPath.startsWith("\"") ||
+ _sPath.startsWith("'"))
+ {
+ // remove trailing quotes, if exists
+ sNewPath = sNewPath.substring(1);
+ }
+
+ if (_sPath.endsWith("\"") ||
+ _sPath.endsWith("'"))
+ {
+ // remove trailing quotes, if exists
+ sNewPath = sNewPath.substring(0, sNewPath.length() - 1);
+ }
+ return sNewPath;
+ }
+
+ public static String doubleQuoteIfNeed(String _sStr)
+ {
+ if (_sStr.startsWith("\"") && _sStr.endsWith("\""))
+ {
+ // don't quote twice
+ return _sStr;
+ }
+ if (_sStr.indexOf(" ") == -1)
+ {
+ // don't quote, if there is no space in name
+ return _sStr;
+ }
+ if (_sStr.indexOf("%") != -1)
+ {
+ return singleQuote(_sStr);
+ }
+
+ return doubleQuote(_sStr);
+ }
+
+ /**
+ * Convert a value to a string with a given length, if the len is greater the len of the value string representation
+ * fill it's front with '0'
+ * So ("5", 4) will result in a string "0005"
+ * @param _nValue
+ * @param _nLen
+ * @return
+ */
+ public static String createValueString(int _nValue, int _nLen)
+ {
+ String sValue = String.valueOf(_nValue);
+ StringBuffer a = new StringBuffer();
+ while (_nLen > sValue.length())
+ {
+ a.append('0');
+ _nLen --;
+ }
+ a.append(sValue);
+ return a.toString();
+ }
+
+}
diff --git a/qadevOOo/runner/helper/URLHelper.java b/qadevOOo/runner/helper/URLHelper.java
new file mode 100644
index 000000000000..39bff1485747
--- /dev/null
+++ b/qadevOOo/runner/helper/URLHelper.java
@@ -0,0 +1,292 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package helper;
+
+// __________ Imports __________
+
+// exceptions
+import java.net.MalformedURLException;
+
+// interfaces
+import com.sun.star.util.XURLTransformer;
+
+// others
+import java.io.File;
+import java.util.Vector;
+import java.util.Enumeration;
+
+
+/**
+ * It collects some static helper functons to handle URLs.
+ * Sometimes it's neccessary to convert URL from/to system pathes.
+ * Or from string to strutural notations (e.g. com.sun.star.util.URL).
+ * And sometimes java had another notation then the office it has.
+ *
+ */
+public class URLHelper
+{
+ // ____________________
+
+ /**
+ * Because the office need URLs for loading/saving documents
+ * we must convert used system pathes.
+ * And java use another notation for file URLs ... correct it.
+ *
+ * @param aSystemPath
+ * represent the file in system notation
+ *
+ * @return [String]
+ * a file url which represent the given system path
+ */
+ public static String getFileURLFromSystemPath( File aSystemPath )
+ {
+ String sFileURL = null;
+ try
+ {
+ //sFileURL = aSystemPath.toURI().toURL().toString();
+ sFileURL = aSystemPath.toURL().toString();
+ }
+ catch( MalformedURLException exWrong )
+ {
+ sFileURL = null;
+ }
+
+ // problem of java: file URL's are coded with 1 slash instead of 2 or 3 ones!
+ // => correct this problem first, otherwise office can't use these URL's
+ if(
+ (sFileURL != null ) &&
+ (sFileURL.startsWith("file:/") == true ) &&
+ (sFileURL.startsWith("file://") == false)
+ )
+ {
+ StringBuffer sWorkBuffer = new StringBuffer(sFileURL);
+ sWorkBuffer.insert(6,"//");
+ sFileURL = sWorkBuffer.toString();
+ }
+
+ return sFileURL;
+ }
+
+ // ____________________
+
+ /**
+ * The same as getFileURLFromSystemPath() before but uses string parameter instead
+ * of a File type. It exist to supress converting of neccessary parameters in the
+ * outside code. But of course getFileURLFromSystemPath(File) will be a little bit faster
+ * then this method ...
+ *
+ * @param sSystemPath
+ * represent the file in system notation
+ *
+ * @return [String]
+ * a file url which represent the given system path
+ */
+ public static String getFileURLFromSystemPath( String sSystemPath )
+ {
+ return getFileURLFromSystemPath(new File(sSystemPath));
+ }
+
+ // ____________________
+
+ /**
+ * Does the same as getFileURLFromSystemPath() before ... but uses
+ * the given protocol string (e.g."http://") insted of "file:///".
+ *
+ * @param aSystemPath
+ * represent the file in system notation
+ *
+ * @param aBasePath
+ * define the base path of the aSystemPath value,
+ * which must be replaced with the value of "sServerPath".
+ *
+ * @param sServerURL
+ * Will be used to replace sBasePath.
+ *
+ * @example
+ * System Path = "d:\test\file.txt"
+ * Base Path = "d:\test"
+ * Server Path = "http://alaska:8000"
+ * => "http://alaska:8000/file.txt"
+ *
+ * @return [String]
+ * an url which represent the given system path
+ * and uses the given protocol
+ */
+ public static String getURLWithProtocolFromSystemPath( File aSystemPath, File aBasePath, String sServerURL )
+ {
+ String sFileURL = URLHelper.getFileURLFromSystemPath(aSystemPath);
+ String sBaseURL = URLHelper.getFileURLFromSystemPath(aBasePath );
+
+ // cut last '/'!
+ if (sBaseURL.lastIndexOf('/')==(sBaseURL.length()-1))
+ sBaseURL = sBaseURL.substring(0,sBaseURL.length()-1);
+
+ // cut last '/'!
+ if (sServerURL.lastIndexOf('/')==(sServerURL.length()-1))
+ sServerURL = sServerURL.substring(0,sServerURL.length()-1);
+
+ int index = sFileURL.indexOf(sBaseURL);
+ String sURL = sFileURL.substring(0,index) + sServerURL +
+ sFileURL.substring(index+sBaseURL.length());
+ //String sURL = sFileURL.replaceFirst(sBaseURL,sServerURL);
+ return sURL;
+ }
+
+ // ____________________
+
+ /**
+ * The same as getURLWithProtocolFromSystemPath() before but uses string parameter instead
+ * of a File types. It exist to supress converting of neccessary parameters in the
+ * outside code. But of course getURLWithProtocolFromSystemPath(File,File,String) will be
+ * a little bit faster then this method ...
+ *
+ * @param sSystemPath
+ * represent the file in system notation
+ *
+ * @param sBasePath
+ * define the base path of the aSystemPath value,
+ * which must be replaced with the value of "sServerPath".
+ *
+ * @param sServerPath
+ * Will be used to replace sBasePath.
+ *
+ * @example
+ * System Path = "d:\test\file.txt"
+ * Base Path = "d:\test"
+ * Server Path = "http://alaska:8000"
+ * => "http://alaska:8000/file.txt"
+ *
+ * @return [String]
+ * an url which represent the given system path
+ * and uses the given protocol
+ */
+ public static String getURLWithProtocolFromSystemPath( String sSystemPath, String sBasePath, String sServerPath )
+ {
+ return getURLWithProtocolFromSystemPath(new File(sSystemPath), new File(sBasePath), sServerPath);
+ }
+
+ // ____________________
+
+ /**
+ * This convert an URL (formated as a string) to a struct com.sun.star.util.URL.
+ * It use a special service to do that: the URLTransformer.
+ * Because some API calls need it and it's not allowed to set "Complete"
+ * part of the util struct only. The URL must be parsed.
+ *
+ * @param sURL
+ * URL for parsing in string notation
+ *
+ * @return [com.sun.star.util.URL]
+ * URL in UNO struct notation
+ */
+ public static com.sun.star.util.URL parseURL(XURLTransformer xParser, String sURL)
+ {
+ com.sun.star.util.URL aURL = null;
+
+ if (sURL==null || sURL.equals(""))
+ return null;
+
+ try
+ {
+ // Create special service for parsing of given URL.
+/* com.sun.star.util.XURLTransformer xParser = (com.sun.star.util.XURLTransformer)OfficeConnect.createRemoteInstance(
+ com.sun.star.util.XURLTransformer.class,
+ "com.sun.star.util.URLTransformer");
+*/
+ // Because it's an in/out parameter we must use an array of URL objects.
+ com.sun.star.util.URL[] aParseURL = new com.sun.star.util.URL[1];
+ aParseURL[0] = new com.sun.star.util.URL();
+ aParseURL[0].Complete = sURL;
+
+ // Parse the URL
+ xParser.parseStrict(aParseURL);
+
+ aURL = aParseURL[0];
+ }
+ catch(com.sun.star.uno.RuntimeException exRuntime)
+ {
+ // Any UNO method of this scope can throw this exception.
+ // Reset the return value only.
+ aURL = null;
+ }
+
+ return aURL;
+ }
+
+ //_________________________________
+ /**
+ * Return a name list of all available files of a directory.
+ * We filter pure sub directories names. All other files
+ * are returned as full qualified URL strings. So they can be
+ * used for further purposes. One parameter define the start directory,
+ * another one describe the url protocol, which the return URL names should have.
+ *
+ * @param sDir
+ * the start directory, which should include all test files
+ *
+ * @return [Vector]
+ * a filtered list of java File objects of all available files of the start dir
+ * and all accessable sub directories.
+ */
+ public static Vector getSystemFilesFromDir(String sStartDir)
+ {
+ File aRoot = new File(sStartDir);
+
+ if (! aRoot.exists())
+ return null;
+
+ if (! aRoot.isDirectory())
+ return null;
+
+ File[] lAllFiles = aRoot.listFiles();
+ if (lAllFiles == null )
+ return null;
+
+ Vector lFilteredFiles = new Vector(lAllFiles.length);
+
+ for (int i=0; i<lAllFiles.length; ++i)
+ {
+ if (lAllFiles[i].isFile())
+ lFilteredFiles.add(lAllFiles[i]);
+ else
+ if (lAllFiles[i].isDirectory())
+ {
+ // recursion!
+ Vector lSubFiles = URLHelper.getSystemFilesFromDir(lAllFiles[i].getPath());
+ if (lSubFiles != null)
+ {
+ Enumeration aSnapshot = lSubFiles.elements();
+ while (aSnapshot.hasMoreElements())
+ lFilteredFiles.add(aSnapshot.nextElement());
+ }
+ }
+ }
+
+ return lFilteredFiles;
+ }
+}
diff --git a/qadevOOo/runner/helper/UnoProvider.java b/qadevOOo/runner/helper/UnoProvider.java
new file mode 100644
index 000000000000..c1c3e63f5ef3
--- /dev/null
+++ b/qadevOOo/runner/helper/UnoProvider.java
@@ -0,0 +1,165 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package helper;
+
+import com.sun.star.comp.helper.Bootstrap;
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import java.util.Hashtable;
+import lib.TestParameters;
+import util.PropertyName;
+import util.utils;
+
+/**
+ * Bootstrap UNO from a Java environment.
+ * Needed parameters:
+ * <ol>
+ * <li>
+ * <ul>
+ * <li>UNORC - complete path to the unorc file</li>
+ * </ul>
+ * </li>
+ * <li>
+ * <ul>
+ * <li>AppExecutionCommand - path to the soffice executable</li>
+ * <li>OS - the operating system in case it's Windows, because the
+ * unorc is called uno.ini</li>
+ * </ul>
+ * </li>
+ * </ol>
+ */
+public class UnoProvider implements AppProvider {
+
+ public UnoProvider(){
+
+ }
+
+ /**
+ * Close existing office: calls disposeManager()
+ * @param param The test parameters.
+ * @param closeIfPossible Not needed, since UNO is bootstrapped by this
+ * class in every case.
+ * @return True, if bootstrapping worked.
+ */
+ public boolean closeExistingOffice(TestParameters param,
+ boolean closeIfPossible) {
+ return disposeManager(param);
+ }
+
+ /**
+ * Dispose the UNO environment: just clears the bootstrapped
+ * MultiServiceFactory
+ * @param param The test parameters.
+ * @return True, if bootstrapping worked.
+ */
+ public boolean disposeManager(TestParameters param) {
+ XMultiServiceFactory xMSF =
+ (XMultiServiceFactory)param.remove("ServiceManager");
+ xMSF = null;
+ System.gc();
+ try {
+ Thread.sleep(1000);
+ }
+ catch(java.lang.InterruptedException e) {}
+ return true;
+ }
+
+ /**
+ * Bootstrap UNO and return the created MultiServiceFactory.
+ * @param param The test parameters.
+ * @return A created MultiServiceFactory.
+ */
+ public Object getManager(TestParameters param) {
+ XMultiServiceFactory xMSF = (XMultiServiceFactory)param.getMSF();
+ if (xMSF == null) {
+ // bootstrap UNO.
+ String unorcName = getUnorcName(param);
+ Hashtable env = new Hashtable();
+ env.put("SYSBINDIR", getSysBinDir(param));
+
+ XComponentContext xContext = null;
+ try {
+ xContext = Bootstrap.defaultBootstrap_InitialComponentContext(
+ unorcName, env);
+ }
+ catch(Exception e) {
+ e.printStackTrace();
+ System.out.println("Could not get XComponentContext. Maybe you must add program folder to LD_LIBRARY_PATH");
+ return null;
+ }
+ XMultiComponentFactory xMCF = xContext.getServiceManager();
+ xMSF = (XMultiServiceFactory)UnoRuntime.queryInterface(
+ XMultiServiceFactory.class, xMCF);
+ }
+ return xMSF;
+ }
+
+ private String getUnorcName(TestParameters param) {
+ String unorcName = (String)param.get("UNORC");
+ if (unorcName == null) {
+ String office = (String)param.get("AppExecutionCommand");
+ // determine unorc name: unorc or uno.ini on windows
+ String opSystem = (String)param.get(PropertyName.OPERATING_SYSTEM);
+ if ( opSystem != null && opSystem.equalsIgnoreCase(PropertyName.WNTMSCI)) {
+ unorcName = "uno.ini";
+ }
+ else {
+ unorcName = "unorc";
+ }
+ if (office == null)
+ return null;
+ // use '/', because this will be a URL in any case.
+ unorcName = office.substring(0, office.indexOf("program")+7) +
+ "/" + unorcName;
+ }
+ unorcName = utils.getFullURL(unorcName);
+ if (param.DebugIsActive) {
+ System.out.println("UnoUcr: " + unorcName);
+ }
+ return unorcName;
+ }
+
+ private String getSysBinDir(TestParameters param) {
+ String base = (String)param.get("AppExecutionCommand");
+ if (base == null)
+ base = (String)param.get("UNORC");
+
+ if (base == null)
+ return null;
+
+ String sysbindir = base.substring(0,
+ base.indexOf("program")+7);
+
+ sysbindir = utils.getFullURL(sysbindir);
+ if (param.DebugIsActive) {
+ System.out.println("SysBinDir: " + sysbindir);
+ }
+ return sysbindir;
+ }
+}
diff --git a/qadevOOo/runner/helper/WindowListener.java b/qadevOOo/runner/helper/WindowListener.java
new file mode 100644
index 000000000000..a19ae27c62c0
--- /dev/null
+++ b/qadevOOo/runner/helper/WindowListener.java
@@ -0,0 +1,78 @@
+/*
+ * WindowListener.java
+ *
+ * Created on 30. Juli 2002, 12:36
+ */
+
+package helper;
+
+/**
+ * An own implementation of a XWindowListener
+ *
+ */
+public class WindowListener implements com.sun.star.awt.XWindowListener {
+
+ // hidden called
+ public boolean hiddenTrigger;
+ // move called
+ public boolean movedTrigger;
+ // resize called
+ public boolean resizedTrigger;
+ // show called
+ public boolean shownTrigger;
+ // dispose called
+ public boolean disposeTrigger;
+
+ /**
+ * Creates a new WindowListener
+ */
+ public WindowListener() {
+ resetTrigger();
+ }
+
+ /**
+ * The window hidden event
+ */
+ public void windowHidden(com.sun.star.lang.EventObject eventObject) {
+ hiddenTrigger = true;
+ }
+
+ /**
+ * The window move event
+ */
+ public void windowMoved(com.sun.star.awt.WindowEvent windowEvent) {
+ movedTrigger = true;
+ }
+
+ /**
+ * The window resize event
+ */
+ public void windowResized(com.sun.star.awt.WindowEvent windowEvent) {
+ resizedTrigger = true;
+ }
+
+ /**
+ * The window show event
+ */
+ public void windowShown(com.sun.star.lang.EventObject eventObject) {
+ shownTrigger = true;
+ }
+
+ /**
+ * The dispose event
+ */
+ public void disposing(com.sun.star.lang.EventObject eventObject) {
+ disposeTrigger = true;
+ }
+
+ /**
+ * Reset all triggers to "not fired".
+ */
+ public void resetTrigger() {
+ hiddenTrigger = false;
+ movedTrigger = false;
+ resizedTrigger = false;
+ shownTrigger = false;
+ disposeTrigger = false;
+ }
+}
diff --git a/qadevOOo/runner/helper/makefile.mk b/qadevOOo/runner/helper/makefile.mk
new file mode 100644
index 000000000000..f5ad34c53ad6
--- /dev/null
+++ b/qadevOOo/runner/helper/makefile.mk
@@ -0,0 +1,65 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME = OOoRunner
+PACKAGE = helper
+TARGET = runner_helper
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+
+JARFILES = ridl.jar jurt.jar juh.jar unoil.jar
+
+JAVAFILES = APIDescGetter.java \
+ ConfigurationRead.java \
+ StreamSimulator.java \
+ AppProvider.java \
+ URLHelper.java \
+ CfgParser.java \
+ SimpleMailSender.java \
+ WindowListener.java \
+ ClParser.java \
+ OfficeWatcher.java \
+ OfficeProvider.java \
+ ComplexDescGetter.java \
+ InetTools.java \
+ ProcessHandler.java \
+ ContextMenuInterceptor.java \
+ UnoProvider.java\
+ PropertyHelper.java\
+ FileTools.java
+
+JAVACLASSFILES= $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk