From 91ab2cabe11981d03007616f55acb0119b0435d7 Mon Sep 17 00:00:00 2001 From: Vladimir Glazounov Date: Mon, 6 Jul 2009 10:30:52 +0000 Subject: CWS-TOOLING: integrate CWS unoapi04 2009-06-26 14:00:27 +0200 lla r273410 : #i102248# cleanups 2009-06-26 13:36:44 +0200 lla r273407 : #i102248# fix problem with too long sleeps and waits 2009-06-26 08:34:17 +0200 lla r273393 : #i102248# cleanups 2009-06-26 08:28:43 +0200 lla r273392 : #i102248# cleanups 2009-06-25 13:17:19 +0200 lla r273379 : #i102248# add prototypes 2009-06-25 11:31:02 +0200 lla r273371 : #i102248# cleanups 2009-06-25 11:15:18 +0200 lla r273370 : #i102248# add a selftest for demonstration. 2009-06-25 10:53:35 +0200 lla r273369 : #i102248# add a selftest for demonstration. 2009-06-25 10:38:10 +0200 lla r273368 : #i102248# add a selftest for demonstration. 2009-06-23 11:09:35 +0200 lla r273266 : #i102248# cleanup 2009-06-23 11:00:15 +0200 lla r273265 : #i10i108248# add cwstestresult to cwscheckapi 2009-06-23 10:59:50 +0200 lla r273264 : #i10i108248# add cwstestresult to cwscheckapi 2009-06-23 10:58:47 +0200 lla r273263 : #i102248# add selftest --- qadevOOo/objdsc/qadevOOo/bogus.SelfTest.csv | 7 + qadevOOo/qa/unoapi/knownissues.xcl | 1 + qadevOOo/qa/unoapi/makefile.mk | 44 ++ qadevOOo/qa/unoapi/qadevOOo.sce | 1 + qadevOOo/runner/base/java_fat.java | 710 +++++++++++---------- qadevOOo/runner/complexlib/ComplexTestCase.java | 2 +- qadevOOo/runner/complexlib/MethodThread.java | 42 +- qadevOOo/runner/helper/APIDescGetter.java | 642 ++++++++++++------- qadevOOo/runner/helper/CwsDataExchangeImpl.java | 76 ++- qadevOOo/runner/helper/ProcessHandler.java | 51 +- qadevOOo/runner/lib/MultiMethodTest.java | 300 +++++---- qadevOOo/runner/share/DescGetter.java | 117 ++-- qadevOOo/runner/util/DesktopTools.java | 4 +- .../tests/java/complex/unoapi/CheckModuleAPI.java | 447 ++++++++----- qadevOOo/tests/java/ifc/qadevooo/_SelfTest.java | 86 +++ qadevOOo/tests/java/mod/_qadevOOo/SelfTest.java | 95 +++ 16 files changed, 1700 insertions(+), 925 deletions(-) create mode 100755 qadevOOo/objdsc/qadevOOo/bogus.SelfTest.csv create mode 100755 qadevOOo/qa/unoapi/knownissues.xcl create mode 100755 qadevOOo/qa/unoapi/makefile.mk create mode 100755 qadevOOo/qa/unoapi/qadevOOo.sce create mode 100755 qadevOOo/tests/java/ifc/qadevooo/_SelfTest.java create mode 100755 qadevOOo/tests/java/mod/_qadevOOo/SelfTest.java diff --git a/qadevOOo/objdsc/qadevOOo/bogus.SelfTest.csv b/qadevOOo/objdsc/qadevOOo/bogus.SelfTest.csv new file mode 100755 index 000000000000..3983a1e88578 --- /dev/null +++ b/qadevOOo/objdsc/qadevOOo/bogus.SelfTest.csv @@ -0,0 +1,7 @@ +# "Name"; +# "com::sun::star::" will overread +# method name which is called +"SelfTest";"com::sun::star::qadevooo::SelfTest";"testmethod()" +"SelfTest";"com::sun::star::qadevooo::SelfTest";"testmethod2()" +"SelfTest";"com::sun::star::qadevooo::SelfTest";"testmethod3()" +# "SelfTest";"com::sun::star::qadevooo::SelfTest#optional";"testmethod4_bogus()" diff --git a/qadevOOo/qa/unoapi/knownissues.xcl b/qadevOOo/qa/unoapi/knownissues.xcl new file mode 100755 index 000000000000..02c509060d97 --- /dev/null +++ b/qadevOOo/qa/unoapi/knownissues.xcl @@ -0,0 +1 @@ +# This file contains all Errors diff --git a/qadevOOo/qa/unoapi/makefile.mk b/qadevOOo/qa/unoapi/makefile.mk new file mode 100755 index 000000000000..936884bfecbc --- /dev/null +++ b/qadevOOo/qa/unoapi/makefile.mk @@ -0,0 +1,44 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2008 by Sun Microsystems, Inc. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.8 $ +# +# 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 +# +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +PRJ=..$/.. + +PRJNAME=qadevOOo +TARGET=qa_unoapi + +.INCLUDE: settings.mk + +.INCLUDE: target.mk + +ALLTAR : UNOAPI_TEST + +UNOAPI_TEST: + +$(SOLARENV)$/bin$/checkapi -sce qadevOOo.sce -xcl knownissues.xcl -tdoc $(PWD)$/testdocuments diff --git a/qadevOOo/qa/unoapi/qadevOOo.sce b/qadevOOo/qa/unoapi/qadevOOo.sce new file mode 100755 index 000000000000..8e24c474e7e8 --- /dev/null +++ b/qadevOOo/qa/unoapi/qadevOOo.sce @@ -0,0 +1 @@ +-o qadevOOo.SelfTest diff --git a/qadevOOo/runner/base/java_fat.java b/qadevOOo/runner/base/java_fat.java index 64f55e8f0814..4afd234cda29 100644 --- a/qadevOOo/runner/base/java_fat.java +++ b/qadevOOo/runner/base/java_fat.java @@ -59,47 +59,55 @@ import util.DynamicClassLoader; * * this class handles tests written in java and running on a fat Office */ -public class java_fat implements TestBase { +public class java_fat implements TestBase +{ - public static boolean debug = false; - public static boolean keepdocument = false; - public static boolean logging = true; - public static boolean newOffice = false; + private static boolean debug = false; + private static boolean keepdocument = false; + private static boolean logging = true; + private static boolean newOffice = false; private DynamicClassLoader dcl = null; - public boolean executeTest(lib.TestParameters param) { - dcl = new DynamicClassLoader(); - - DescGetter dg = new APIDescGetter(); - String job = (String) param.get("TestJob"); - String ExclusionFile = (String) param.get("ExclusionList"); - Vector exclusions = null; - boolean retValue = true; - debug = param.getBool("DebugIsActive"); - logging = param.getBool("LoggingIsActive"); - keepdocument = param.getBool("KeepDocument"); - newOffice = param.getBool(util.PropertyName.NEW_OFFICE_INSTANCE); - if (keepdocument) { - System.setProperty("KeepDocument", "true"); - } - if (ExclusionFile != null) { - exclusions = getExclusionList(ExclusionFile, debug); - } - //get Job-Descriptions - System.out.println("Getting Descriptions for Job: " + job); + private lib.TestParameters m_aParams; + private AppProvider m_aOffice; - DescEntry[] entries = dg.getDescriptionFor(job, - (String) param.get( - "DescriptionPath"), - debug); + public boolean executeTest(lib.TestParameters param) + { + m_aParams = param; - System.out.println(); + dcl = new DynamicClassLoader(); - if (entries == null) { - System.out.println("Couldn't get Description for Job: " + job); + DescGetter dg = new APIDescGetter(); + String job = (String) param.get("TestJob"); + String ExclusionFile = (String) param.get("ExclusionList"); + Vector exclusions = null; + boolean retValue = true; + debug = param.getBool("DebugIsActive"); + logging = param.getBool("LoggingIsActive"); + keepdocument = param.getBool("KeepDocument"); + newOffice = param.getBool(util.PropertyName.NEW_OFFICE_INSTANCE); + if (keepdocument) + { + System.setProperty("KeepDocument", "true"); + } + if (ExclusionFile != null) + { + exclusions = getExclusionList(ExclusionFile, debug); + } + //get Job-Descriptions + System.out.println("Getting Descriptions for Job: " + job); - return false; - } + String sDescriptionPath = (String) param.get("DescriptionPath"); + DescEntry[] entries = dg.getDescriptionFor(job, sDescriptionPath, debug); + + // System.out.println(); + + if (entries == null) + { + System.out.println("Couldn't get Description for Job: " + job); + + return false; + } // String officeProviderName = (String) param.get("OfficeProvider"); // AppProvider office = (AppProvider) dcl.getInstance(officeProviderName); @@ -110,265 +118,276 @@ public class java_fat implements TestBase { // System.exit(-1); // } - AppProvider office = startOffice(param); - - boolean firstRun = true; + m_aOffice = startOffice(param); - for (int l = 0; l < entries.length; l++) { - if (entries[l] == null) { - continue; - } + boolean firstRun = true; - if (entries[l].hasErrorMsg) { - System.out.println(entries[l].ErrorMsg); + for (int l = 0; l < entries.length; l++) + { + if (entries[l] == null) + { + continue; + } - continue; - } + if (entries[l].hasErrorMsg) + { + System.out.println(entries[l].ErrorMsg); + retValue = false; + continue; + } - if (!firstRun && newOffice) { - if (!office.closeExistingOffice(param, true)) { - office.disposeManager(param); + if (!firstRun && newOffice) + { + if (!m_aOffice.closeExistingOffice(param, true)) + { + m_aOffice.disposeManager(param); + } + startOffice(param); } - startOffice(param); - } - firstRun = false; + firstRun = false; // XMultiServiceFactory msf = (XMultiServiceFactory) office.getManager( // param); - XMultiServiceFactory msf = (XMultiServiceFactory) param.getMSF(); + XMultiServiceFactory msf = (XMultiServiceFactory) param.getMSF(); - if (msf == null) { - retValue = false; + if (msf == null) + { + retValue = false; - continue; - } + continue; + } // param.put("ServiceFactory", msf); - DescEntry entry = entries[l]; - - //get some helper classes - Summarizer sumIt = new Summarizer(); + DescEntry entry = entries[l]; - TestCase tCase = null; - - try { - tCase = (TestCase) dcl.getInstance("mod._" + - entry.entryName); - } catch (java.lang.IllegalArgumentException ie) { - entry.ErrorMsg = ie.getMessage(); - entry.hasErrorMsg = true; - } catch (java.lang.NoClassDefFoundError ie) { - entry.ErrorMsg = ie.getMessage(); - entry.hasErrorMsg = true; - } - - if (tCase == null) { - Summarizer.summarizeDown(entry, entry.ErrorMsg); - - LogWriter sumObj = OutProducerFactory.createOutProducer(param); - entry.UserDefinedParams = param; - sumObj.initialize(entry, logging); - sumObj.summary(entry); + //get some helper classes + Summarizer sumIt = new Summarizer(); - continue; - } + TestCase tCase = null; - if (debug) { - System.out.println("sleeping 5 seconds.."); - } - util.utils.shortWait(5000); + try + { + tCase = (TestCase) dcl.getInstance("mod._" + entry.entryName); + } + catch (java.lang.IllegalArgumentException ie) + { + entry.ErrorMsg = ie.getMessage(); + entry.hasErrorMsg = true; + } + catch (java.lang.NoClassDefFoundError ie) + { + entry.ErrorMsg = ie.getMessage(); + entry.hasErrorMsg = true; + } - System.out.println("Creating: " + entry.entryName); + if (tCase == null) + { + Summarizer.summarizeDown(entry, entry.ErrorMsg); - LogWriter log = (LogWriter) dcl.getInstance( - (String) param.get("LogWriter")); - log.initialize(entry, logging); - entry.UserDefinedParams = param; + LogWriter sumObj = OutProducerFactory.createOutProducer(param); + entry.UserDefinedParams = param; + sumObj.initialize(entry, logging); + sumObj.summary(entry); - TestEnvironment tEnv = null; + continue; + } - try { - tCase.setLogWriter((PrintWriter) log); - tCase.initializeTestCase(param); - tEnv = tCase.getTestEnvironment(param); - } catch (Exception e) { - System.out.println("Exception while creating " + - tCase.getObjectName()); - System.out.println("Message " + e.getMessage()); - e.printStackTrace(); - tEnv = null; - } catch (java.lang.UnsatisfiedLinkError e) { - System.out.println("Exception while creating " + - tCase.getObjectName()); - System.out.println("Message " + e.getMessage()); - tEnv = null; - } catch (java.lang.NoClassDefFoundError e) { - System.out.println("Exception while creating " + - tCase.getObjectName()); - System.out.println("Message " + e.getMessage()); - tEnv = null; - } + if (debug) + { + System.out.println("sleeping 5 seconds.."); + } + util.utils.shortWait(5000); - if (tEnv == null) { - Summarizer.summarizeDown(entry, - "Couldn't create " + - tCase.getObjectName()); + System.out.println("Creating: " + entry.entryName); - LogWriter sumObj = OutProducerFactory.createOutProducer(param); + LogWriter log = (LogWriter) dcl.getInstance((String) param.get("LogWriter")); + log.initialize(entry, logging); entry.UserDefinedParams = param; - sumObj.initialize(entry, logging); - sumObj.summary(entry); - - continue; - } - System.out.println(tCase.getObjectName() + " recreated "); + TestEnvironment tEnv = null; - for (int j = 0; j < entry.SubEntryCount; j++) { - if (!entry.SubEntries[j].isToTest) { - Summarizer.summarizeDown(entry.SubEntries[j], - "not part of the job"); - - continue; + try + { + tCase.setLogWriter((PrintWriter) log); + tCase.initializeTestCase(param); + tEnv = tCase.getTestEnvironment(param); } + catch (Exception e) + { + System.out.println("Exception while creating " + tCase.getObjectName()); + System.out.println("Message " + e.getMessage()); + e.printStackTrace(); + tEnv = null; + } + catch (java.lang.UnsatisfiedLinkError e) + { + System.out.println("Exception while creating " + tCase.getObjectName()); + System.out.println("Message " + e.getMessage()); + tEnv = null; + } + catch (java.lang.NoClassDefFoundError e) + { + System.out.println("Exception while creating " + tCase.getObjectName()); + System.out.println("Message " + e.getMessage()); + tEnv = null; + } + + if (tEnv == null) + { + Summarizer.summarizeDown(entry, "Couldn't create " + tCase.getObjectName()); - if ((exclusions != null) && (exclusions.contains(entry.SubEntries[j].longName))) { - Summarizer.summarizeDown(entry.SubEntries[j], - "known issue"); + LogWriter sumObj = OutProducerFactory.createOutProducer(param); + entry.UserDefinedParams = param; + sumObj.initialize(entry, logging); + sumObj.summary(entry); continue; } - System.out.println("running: '" + entry.SubEntries[j].entryName + "'"); + System.out.println(tCase.getObjectName() + " recreated "); - LogWriter ifclog = (LogWriter) dcl.getInstance( - (String) param.get("LogWriter")); + for (int j = 0; j < entry.SubEntryCount; j++) + { + DescEntry aSubEntry = entry.SubEntries[j]; + if (!aSubEntry.isToTest) + { + Summarizer.summarizeDown(aSubEntry, "not part of the job"); - ifclog.initialize(entry.SubEntries[j], logging); - entry.SubEntries[j].UserDefinedParams = param; - entry.SubEntries[j].Logger = ifclog; + continue; + } - if ((tEnv == null) || tEnv.isDisposed()) { - helper.ProcessHandler ph = (helper.ProcessHandler) param.get( - "AppProvider"); + if ((exclusions != null) && (exclusions.contains(aSubEntry.longName))) + { + Summarizer.summarizeDown(aSubEntry, "known issue"); - if (ph != null) { - office.closeExistingOffice(param, true); - shortWait(5000); + continue; } - tEnv = getEnv(entry, param); - } + System.out.println("running: '" + aSubEntry.entryName + "'"); - MultiMethodTest ifc = null; - lib.TestResult res = null; - - // run the interface test twice if it failed. - int countInterfaceTestRun = 0; - boolean finished = false; - while (!finished) { - try { - countInterfaceTestRun++; - finished = true; - res = executeInterfaceTest(entry.SubEntries[j], tEnv, param); - } catch (IllegalArgumentException iae) { - System.out.println("Couldn't load class " + - entry.SubEntries[j].entryName); - System.out.println("**** " + iae.getMessage() + " ****"); - Summarizer.summarizeDown(entry.SubEntries[j], - iae.getMessage()); - } catch (java.lang.NoClassDefFoundError iae) { - System.out.println("Couldn't load class " + - entry.SubEntries[j].entryName); - System.out.println("**** " + iae.getMessage() + " ****"); - Summarizer.summarizeDown(entry.SubEntries[j], - iae.getMessage()); - } catch (java.lang.RuntimeException e) { - helper.ProcessHandler ph = (helper.ProcessHandler) param.get( - "AppProvider"); - - if (ph != null) { - office.closeExistingOffice(param, true); - shortWait(5000); - } + LogWriter ifclog = (LogWriter) dcl.getInstance( (String) param.get("LogWriter")); + + ifclog.initialize(aSubEntry, logging); + aSubEntry.UserDefinedParams = param; + aSubEntry.Logger = ifclog; + if ((tEnv == null) || tEnv.isDisposed()) + { + closeExistingOffice(); tEnv = getEnv(entry, param); - if (countInterfaceTestRun < 2) { - finished = false; - } else { - Summarizer.summarizeDown(entry.SubEntries[j], - e.toString() + ".FAILED"); + } + + MultiMethodTest ifc = null; + lib.TestResult res = null; + + // run the interface test twice if it failed. + int countInterfaceTestRun = 0; + boolean finished = false; + while (!finished) + { + try + { + countInterfaceTestRun++; + finished = true; + res = executeInterfaceTest(aSubEntry, tEnv, param); + } + catch (IllegalArgumentException iae) + { + System.out.println("Couldn't load class " + aSubEntry.entryName); + System.out.println("**** " + iae.getMessage() + " ****"); + Summarizer.summarizeDown(aSubEntry, iae.getMessage()); + } + catch (java.lang.NoClassDefFoundError iae) + { + System.out.println("Couldn't load class " + aSubEntry.entryName); + System.out.println("**** " + iae.getMessage() + " ****"); + Summarizer.summarizeDown(aSubEntry, iae.getMessage()); + } + catch (java.lang.RuntimeException e) + { + closeExistingOffice(); + tEnv = getEnv(entry, param); + if (countInterfaceTestRun < 2) + { + finished = false; + } + else + { + Summarizer.summarizeDown(aSubEntry, e.toString() + ".FAILED"); + } } } - } - if (res != null) { - for (int k = 0; k < entry.SubEntries[j].SubEntryCount; k++) { - if (res.hasMethod( - entry.SubEntries[j].SubEntries[k].entryName)) { - entry.SubEntries[j].SubEntries[k].State = res.getStatusFor( - entry.SubEntries[j].SubEntries[k].entryName).toString(); + if (res != null) + { + for (int k = 0; k < aSubEntry.SubEntryCount; k++) + { + DescEntry aSubSubEntry = aSubEntry.SubEntries[k]; + if (res.hasMethod( aSubSubEntry.entryName)) + { + aSubSubEntry.State = res.getStatusFor(aSubSubEntry.entryName).toString(); + } } } - } - sumIt.summarizeUp(entry.SubEntries[j]); + sumIt.summarizeUp(aSubEntry); - LogWriter sumIfc = OutProducerFactory.createOutProducer(param); - entry.SubEntries[j].UserDefinedParams = param; - sumIfc.initialize(entry.SubEntries[j], logging); - sumIfc.summary(entry.SubEntries[j]); - } + LogWriter sumIfc = OutProducerFactory.createOutProducer(param); + aSubEntry.UserDefinedParams = param; + sumIfc.initialize(aSubEntry, logging); + sumIfc.summary(aSubEntry); + } - try { - if (!keepdocument) { - tCase.cleanupTestCase(param); + try + { + if (!keepdocument) + { + tCase.cleanupTestCase(param); + } + } + catch (Exception e) + { + System.out.println("couldn't cleanup"); + } + catch (java.lang.NoClassDefFoundError e) + { + System.out.println("couldn't cleanup"); } - } catch (Exception e) { - System.out.println("couldn't cleanup"); - } catch (java.lang.NoClassDefFoundError e) { - System.out.println("couldn't cleanup"); - } - sumIt.summarizeUp(entry); + sumIt.summarizeUp(entry); - LogWriter sumObj = OutProducerFactory.createOutProducer(param); + LogWriter sumObj = OutProducerFactory.createOutProducer(param); - sumObj.initialize(entry, logging); - sumObj.summary(entry); - } + sumObj.initialize(entry, logging); + sumObj.summary(entry); + } - if (entries.length > 1) { - System.out.println(); + if (entries.length > 0) + { + System.out.println(); - int counter = 0; - System.out.println( - "Failures that appeared during scenario execution:"); + int counter = 0; + System.out.println("Failures that appeared during scenario execution:"); - for (int i = 0; i < entries.length; i++) { - if (!entries[i].State.endsWith("OK")) { - System.out.println("\t " + entries[i].longName); - counter++; + for (int i = 0; i < entries.length; i++) + { + if (!entries[i].State.endsWith("OK")) + { + System.out.println("\t " + entries[i].longName); + counter++; + } } - } - - System.out.println(counter + " of " + entries.length + - " tests failed"); - } - helper.ProcessHandler ph = (helper.ProcessHandler) param.get( - "AppProvider"); + System.out.println(counter + " of " + entries.length + " tests failed"); + } - if (ph != null) { - office.closeExistingOffice(param, true); - shortWait(5000); + closeExistingOffice(); + return retValue; } - return retValue; - } - - protected TestEnvironment getEnv(DescEntry entry, TestParameters param) { + private TestEnvironment getEnv(DescEntry entry, TestParameters param) + { // if (dcl == null) // dcl = new DynamicClassLoader(); // String officeProviderName = (String) param.get("OfficeProvider"); @@ -389,143 +408,172 @@ public class java_fat implements TestBase { // // param.put("ServiceFactory", msf); - AppProvider office = startOffice(param); + // AppProvider office = startOffice(param); - TestCase tCase = null; + TestCase tCase = null; - try { - tCase = (TestCase) dcl.getInstance("mod._" + entry.entryName); - } catch (java.lang.IllegalArgumentException ie) { - entry.ErrorMsg = ie.getMessage(); - entry.hasErrorMsg = true; - } catch (java.lang.NoClassDefFoundError ie) { - entry.ErrorMsg = ie.getMessage(); - entry.hasErrorMsg = true; - } + try + { + tCase = (TestCase) dcl.getInstance("mod._" + entry.entryName); + } + catch (java.lang.IllegalArgumentException ie) + { + entry.ErrorMsg = ie.getMessage(); + entry.hasErrorMsg = true; + } + catch (java.lang.NoClassDefFoundError ie) + { + entry.ErrorMsg = ie.getMessage(); + entry.hasErrorMsg = true; + } - System.out.println("Creating: " + entry.entryName); + System.out.println("Creating: " + entry.entryName); - entry.UserDefinedParams = param; + entry.UserDefinedParams = param; - LogWriter log = (LogWriter) dcl.getInstance( - (String) param.get("LogWriter")); - log.initialize(entry, logging); - tCase.setLogWriter((PrintWriter) log); + LogWriter log = (LogWriter) dcl.getInstance((String) param.get("LogWriter")); + log.initialize(entry, logging); + tCase.setLogWriter((PrintWriter) log); - TestEnvironment tEnv = null; + TestEnvironment tEnv = null; - try { - tCase.initializeTestCase(param); - tEnv = tCase.getTestEnvironment(param); - } catch (com.sun.star.lang.DisposedException de) { - System.out.println("Office disposed"); + try + { + tCase.initializeTestCase(param); + tEnv = tCase.getTestEnvironment(param); + } + catch (com.sun.star.lang.DisposedException de) + { + System.out.println("Office disposed"); + closeExistingOffice(); + } + catch (lib.StatusException e) + { + System.out.println(e.getMessage()); - helper.ProcessHandler ph = (helper.ProcessHandler) param.get( - "AppProvider"); + closeExistingOffice(); - if (ph != null) { - office.closeExistingOffice(param, true); - shortWait(5000); + entry.ErrorMsg = e.getMessage(); + entry.hasErrorMsg = true; } - } catch (lib.StatusException e) { - System.out.println(e.getMessage()); - helper.ProcessHandler ph = (helper.ProcessHandler) param.get( - "AppProvider"); + return tEnv; + } - if (ph != null) { - office.closeExistingOffice(param, true); + private void closeExistingOffice() + { + helper.ProcessHandler ph = (helper.ProcessHandler) m_aParams.get("AppProvider"); + + if (ph != null) + { + m_aOffice.closeExistingOffice(m_aParams, true); shortWait(5000); } - entry.ErrorMsg = e.getMessage(); - entry.hasErrorMsg = true; } - return tEnv; - } - - protected void shortWait(int millis) { - try { - Thread.sleep(millis); - } catch (java.lang.InterruptedException ie) { + private void shortWait(int millis) + { + try + { + Thread.sleep(millis); + } + catch (java.lang.InterruptedException ie) + { + } } - } - - protected Vector getExclusionList(String url, boolean debug) { - Vector entryList = new Vector(); - String line = "#"; - BufferedReader exclusion = null; - - try { - exclusion = new BufferedReader(new FileReader(url)); - } catch (java.io.FileNotFoundException fnfe) { - if (debug) { - System.out.println("Couldn't find file " + url); + + private Vector getExclusionList(String url, boolean debug) + { + Vector entryList = new Vector(); + String line = "#"; + BufferedReader exclusion = null; + + try + { + exclusion = new BufferedReader(new FileReader(url)); } + catch (java.io.FileNotFoundException fnfe) + { + if (debug) + { + System.out.println("Couldn't find file " + url); + } - return entryList; - } + return entryList; + } + + while (line != null) + { + try + { + if (!line.startsWith("#") && (line.length() > 1)) + { + entryList.add(line.trim()); + } - while (line != null) { - try { - if (!line.startsWith("#") && (line.length() > 1)) { - entryList.add(line.trim()); + line = exclusion.readLine(); } + catch (java.io.IOException ioe) + { + if (debug) + { + System.out.println("Exception while reading exclusion list"); + } - line = exclusion.readLine(); - } catch (java.io.IOException ioe) { - if (debug) { - System.out.println( - "Exception while reading exclusion list"); + return entryList; } + } - return entryList; + try + { + exclusion.close(); } - } + catch (java.io.IOException ioe) + { + if (debug) + { + System.out.println("Couldn't close file " + url); + } - try { - exclusion.close(); - } catch (java.io.IOException ioe) { - if (debug) { - System.out.println("Couldn't close file " + url); + return entryList; } return entryList; } - return entryList; - } - private TestResult executeInterfaceTest( DescEntry entry, TestEnvironment tEnv, TestParameters param) - throws IllegalArgumentException, java.lang.NoClassDefFoundError { - MultiMethodTest ifc = (MultiMethodTest) dcl.getInstance(entry.entryName); - return ifc.run(entry, tEnv, param); - } + throws IllegalArgumentException, java.lang.NoClassDefFoundError + { + MultiMethodTest ifc = (MultiMethodTest) dcl.getInstance(entry.entryName); + return ifc.run(entry, tEnv, param); + } - private AppProvider startOffice(lib.TestParameters param) { + private AppProvider startOffice(lib.TestParameters param) + { - if (dcl == null) { - dcl = new DynamicClassLoader(); - } + if (dcl == null) + { + dcl = new DynamicClassLoader(); + } - String officeProviderName = (String) param.get("OfficeProvider"); - AppProvider office = (AppProvider) dcl.getInstance(officeProviderName); + String officeProviderName = (String) param.get("OfficeProvider"); + AppProvider office = (AppProvider) dcl.getInstance(officeProviderName); - if (office == null) { - System.out.println("ERROR: Wrong parameter 'OfficeProvider', " + - " it cannot be instantiated."); - System.exit(-1); - } + if (office == null) + { + System.out.println("ERROR: Wrong parameter 'OfficeProvider', " + " it cannot be instantiated."); + System.exit(-1); + } - XMultiServiceFactory msf = (XMultiServiceFactory) office.getManager( - param); + XMultiServiceFactory msf = (XMultiServiceFactory) office.getManager(param); - if (msf != null){ - param.put("ServiceFactory", msf); - } + if (msf != null) + { + param.put("ServiceFactory", msf); + } - return office; - } + return office; + } } diff --git a/qadevOOo/runner/complexlib/ComplexTestCase.java b/qadevOOo/runner/complexlib/ComplexTestCase.java index f31cf1810106..ded9b1c0099d 100644 --- a/qadevOOo/runner/complexlib/ComplexTestCase.java +++ b/qadevOOo/runner/complexlib/ComplexTestCase.java @@ -280,4 +280,4 @@ public abstract class ComplexTestCase extends Assurance implements ComplexTest { return this.getClass().getName(); } -} \ No newline at end of file +} diff --git a/qadevOOo/runner/complexlib/MethodThread.java b/qadevOOo/runner/complexlib/MethodThread.java index b08b93b532fd..e068323fd41e 100644 --- a/qadevOOo/runner/complexlib/MethodThread.java +++ b/qadevOOo/runner/complexlib/MethodThread.java @@ -7,7 +7,8 @@ import java.lang.reflect.Method; * Invoke a method of a class in an own thread. Provide a method to end * the thread. */ -public class MethodThread extends Thread { +public class MethodThread extends Thread +{ /** The method that should be executed **/ private Method mTestMethod = null; @@ -19,7 +20,6 @@ public class MethodThread extends Thread { private String mErrMessage = null; /** Did an Exception happen? **/ private boolean mExceptionHappened = false; - private Object[] mParameter = null; /** @@ -28,13 +28,15 @@ public class MethodThread extends Thread { * @param invokeClass The class where the method is invoked. * @param log The logging mechanism. */ - public MethodThread(Method testMethod, Object invokeClass, PrintWriter log) { + public MethodThread(Method testMethod, Object invokeClass, PrintWriter log) + { mTestMethod = testMethod; mInvokeClass = invokeClass; mLog = log; } - public MethodThread(Method testMethod, Object invokeClass, Object[] parameter, PrintWriter log) { + public MethodThread(Method testMethod, Object invokeClass, Object[] parameter, PrintWriter log) + { mTestMethod = testMethod; mInvokeClass = invokeClass; mParameter = parameter; @@ -44,22 +46,29 @@ public class MethodThread extends Thread { /** * Invoke the method. */ - public void run() { - try { + public void run() + { + try + { mTestMethod.invoke(mInvokeClass, mParameter); } - catch(IllegalAccessException e) { + catch (IllegalAccessException e) + { e.printStackTrace(mLog); mErrMessage = e.getMessage(); mExceptionHappened = true; } - catch(java.lang.reflect.InvocationTargetException e) { + catch (java.lang.reflect.InvocationTargetException e) + { Throwable t = e.getTargetException(); - if (!(t instanceof ComplexTestCase.AssureException)) { + if (!(t instanceof ComplexTestCase.AssureException)) + { t.printStackTrace(mLog); mErrMessage = t.getMessage(); if (mErrMessage == null) + { mErrMessage = t.toString(); + } mExceptionHappened = true; } @@ -70,7 +79,8 @@ public class MethodThread extends Thread { * Get the error message * @return The error message. */ - public String getErrorMessage() { + public String getErrorMessage() + { return mErrMessage; } @@ -78,18 +88,22 @@ public class MethodThread extends Thread { * Is there an error message? * @return True, if an error did happen. */ - public boolean hasErrorMessage() { + public boolean hasErrorMessage() + { return mExceptionHappened; } /** * Stop the running method. */ - public void destroy() { - try { + public void destroy() + { + try + { interrupt(); } - catch(SecurityException e) { + catch (SecurityException e) + { e.printStackTrace(mLog); mErrMessage = e.getMessage(); mExceptionHappened = true; diff --git a/qadevOOo/runner/helper/APIDescGetter.java b/qadevOOo/runner/helper/APIDescGetter.java index cf57c0d26110..3f29e6a97b39 100644 --- a/qadevOOo/runner/helper/APIDescGetter.java +++ b/qadevOOo/runner/helper/APIDescGetter.java @@ -42,7 +42,6 @@ import java.util.StringTokenizer; import share.DescEntry; import share.DescGetter; - /** * This is the Office-API specific DescGetter
*
@@ -68,11 +67,11 @@ import share.DescGetter; * -sce sw.SwXBodyText,sw.SwXBookmark
* runs the module test of Sw.SwXBodyText and sw.SwXBookmark
*/ +public class APIDescGetter extends DescGetter +{ -public class APIDescGetter extends DescGetter { private static String fullJob = null; - /* * gets the needed information about a StarOffice component * @param descPath Path to the ComponentDescription @@ -80,102 +79,136 @@ public class APIDescGetter extends DescGetter { * @param debug if true some debug information is displayed on standard out */ public DescEntry[] getDescriptionFor(String job, String descPath, - boolean debug) { + boolean debug) + { - if (job.startsWith("-o")) { + if (job.startsWith("-o")) + { job = job.substring(3, job.length()).trim(); - if (job.indexOf(".") < 0) { + if (job.indexOf(".") < 0) + { return null; } // special in case several Interfaces are given comma separated - if (job.indexOf(",") < 0) { + if (job.indexOf(",") < 0) + { DescEntry entry = getDescriptionForSingleJob(job, descPath, - debug); - - if (entry != null) { - return new DescEntry[] { entry }; - } else { + debug); + + if (entry != null) + { + return new DescEntry[] + { + entry + }; + } + else + { return null; } - } else { + } + else + { ArrayList subs = getSubInterfaces(job); String partjob = job.substring(0, job.indexOf(",")).trim(); DescEntry entry = getDescriptionForSingleJob(partjob, descPath, - debug); + debug); - if (entry != null) { - for (int i = 0; i < entry.SubEntryCount; i++) { + 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()); + subEntry.length()); - if (subs.contains(subEntry)) { + if (subs.contains(subEntry)) + { entry.SubEntries[i].isToTest = true; } } - return new DescEntry[] { entry }; - } else { + return new DescEntry[] + { + entry + }; + } + else + { return null; } } } - if (job.startsWith("-p")) { + if (job.startsWith("-p")) + { job = job.substring(3, job.length()).trim(); String[] scenario = createScenario(descPath, job, debug); - if (scenario == null) { + if (scenario == null) + { return null; } DescEntry[] entries = new DescEntry[scenario.length]; - for (int i=0;i 0; fullJob = job; - if (isSingleInterface) { + if (isSingleInterface) + { job = job.substring(0, job.indexOf("::")); } - if (job.startsWith("bugs")) { + if (job.startsWith("bugs")) + { DescEntry Entry = new DescEntry(); Entry.entryName = job; Entry.longName = job; @@ -191,14 +224,19 @@ public class APIDescGetter extends DescGetter { DescEntry entry = null; - if (descPath != null) { - if (debug) { + if (descPath != null) + { + if (debug) + { System.out.println("## reading from File " + descPath); } entry = getFromDirectory(descPath, job, debug); - } else { - if (debug) { + } + else + { + if (debug) + { System.out.println("## reading from jar"); } @@ -207,139 +245,161 @@ public class APIDescGetter extends DescGetter { boolean foundInterface = false; - if (isSingleInterface && (entry != null)) { - for (int i = 0; i < entry.SubEntryCount; i++) { - if (!(entry.SubEntries[i].longName).equals(fullJob)) { + 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 { + } + else + { foundInterface = true; entry.SubEntries[i].isToTest = true; } } } - if (isSingleInterface && !foundInterface || entry == null) { + if (isSingleInterface && !foundInterface || entry == null) + { return setErrorDescription(entry, - "couldn't find a description for test '" + fullJob+ "'"); + "couldn't find a description for test '" + fullJob + "'"); } return entry; } protected static DescEntry[] getSubEntries(BufferedReader cvsFile, - DescEntry parent, boolean debug) { + DescEntry parent, boolean debug) + { String line = ""; String old_ifc_name = ""; ArrayList ifc_names = new ArrayList(); ArrayList meth_names = new ArrayList(); DescEntry ifcDesc = null; - DescEntry methDesc = null; - String entryType = "service"; - while (line != null) { - try { + 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()); + } - if ((line != null) && (line.length() > 0)) { - String ifc_name = line.substring(line.indexOf(";") + 2, - line.lastIndexOf(";") - 1); - String meth_name = line.substring(line.lastIndexOf(";") + 2, - line.length() - 1); - - 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; + // String ifc_name = line.substring(line.indexOf(";") + 2, line.lastIndexOf(";") - 1); + // String meth_name = line.substring(line.lastIndexOf(";") + 2, line.length() - 1); - if (!ifc_name.equals(old_ifc_name)) { - if (ifcDesc != null) { - ifcDesc.SubEntries = getDescArray( - meth_names.toArray()); - ifcDesc.SubEntryCount = meth_names.size(); + DescEntry methDesc = createDescEntry(meth_name, ifc_name, parent); + meth_names.add(methDesc); - //mark service/interface as optional if all methods/properties are optional - boolean allOptional = true; + if (!ifc_name.equals(old_ifc_name)) + { + if (ifcDesc != null) + { + ifcDesc.SubEntries = getDescArray(meth_names.toArray()); + ifcDesc.SubEntryCount = meth_names.size(); - for (int k = 0; k < ifcDesc.SubEntryCount; k++) { - if (!ifcDesc.SubEntries[k].isOptional) { - allOptional = false; - } - } + //mark service/interface as optional if all methods/properties are optional + boolean allOptional = true; - if (!ifcDesc.isOptional && allOptional) { - ifcDesc.isOptional = allOptional; + for (int k = 0; k < ifcDesc.SubEntryCount; k++) + { + if (!ifcDesc.SubEntries[k].isOptional) + { + allOptional = false; } - - 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("#")); + if (!ifcDesc.isOptional && allOptional) + { + ifcDesc.isOptional = allOptional; } - StringTokenizer st = new StringTokenizer(ifc_name, ":"); - String className = ""; + meth_names.clear(); + ifc_names.add(ifcDesc); + } - int count = 3; + ifcDesc = new DescEntry(); + ifcDesc.isToTest = true; + old_ifc_name = ifc_name; - if (ifc_name.startsWith("drafts")) { - count = 4; - } + if (ifc_name.indexOf("#optional") > 0) + { + ifcDesc.isOptional = true; + ifc_name = ifc_name.substring(0, ifc_name.indexOf("#")); + } + + StringTokenizer st = new StringTokenizer(ifc_name, ":"); + String className = ""; - for (int i = 0; st.hasMoreTokens(); i++) { - String token = st.nextToken(); + int count = 3; - // skipping (drafts.)com.sun.star - if (i >= count) { - if (!st.hasMoreTokens()) { - // inserting '_' before the last token - token = "_" + token; - } + if (ifc_name.startsWith("drafts")) + { + count = 4; + } - className += ("." + token); + 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; } - } - ifcDesc.EntryType = entryType; - ifcDesc.entryName = "ifc" + className; - ifcDesc.longName = parent.entryName + "::" + - ifc_name; + className += ("." + token); + } } - meth_names.add(methDesc); + ifcDesc.EntryType = entryType; + ifcDesc.entryName = "ifc" + className; + ifcDesc.longName = parent.entryName + "::" + ifc_name; } - } catch (java.io.IOException ioe) { + + } + catch (java.io.IOException ioe) + { parent.hasErrorMsg = true; parent.ErrorMsg = "IOException while reading the description"; @@ -353,13 +413,16 @@ public class APIDescGetter extends DescGetter { //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) { + for (int k = 0; k < ifcDesc.SubEntryCount; k++) + { + if (!ifcDesc.SubEntries[k].isOptional) + { allOptional = false; } } - if (!ifcDesc.isOptional && allOptional) { + if (!ifcDesc.isOptional && allOptional) + { ifcDesc.isOptional = allOptional; } @@ -368,25 +431,74 @@ public class APIDescGetter extends DescGetter { return getDescArray(makeArray(ifc_names)); } + 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) { + 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++) { + for (int k = 0; k < entriesArray.length; k++) + { DescEntry entry = (DescEntry) entriesArray[k]; - if (entry.entryName.equals("ifc.lang._XComponent")) { + if (entry.entryName.equals("ifc.lang._XComponent")) + { addAtEnd = entry; - } else { + } + else + { returnArray.add(entry); } } - if (addAtEnd != null) { + if (addAtEnd != null) + { returnArray.add(addAtEnd); } @@ -394,40 +506,50 @@ public class APIDescGetter extends DescGetter { } protected static DescEntry setErrorDescription(DescEntry entry, - String ErrorMsg) { + 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; + fullJob + "' as an API test: " + ErrorMsg; return entry; } - protected static DescEntry[] getDescArray(Object[] list) { + protected static DescEntry[] getDescArray(Object[] list) + { DescEntry[] entries = new DescEntry[list.length]; - for (int i = 0; i < list.length; i++) { + for (int i = 0; i < list.length; i++) + { entries[i] = (DescEntry) list[i]; } return entries; } - protected DescEntry getFromClassPath(String aEntry, boolean debug) { + protected DescEntry getFromClassPath(String aEntry, boolean debug) + { int dotindex = aEntry.indexOf('.'); - if (dotindex == -1) { + if (dotindex == -1) + { return null; } String module = null; String shortName = null; - if (aEntry.indexOf(".uno") == -1) { + if (aEntry.indexOf(".uno") == -1) + { module = aEntry.substring(0, aEntry.indexOf('.')); shortName = aEntry.substring(aEntry.indexOf('.') + 1); - } else { + } + else + { module = aEntry.substring(0, aEntry.lastIndexOf('.')); shortName = aEntry.substring(aEntry.lastIndexOf('.') + 1); } @@ -443,22 +565,28 @@ public class APIDescGetter extends DescGetter { java.net.URL url = this.getClass().getResource("/objdsc/" + module); - if (url == null) { + if (url == null) + { return setErrorDescription(theEntry, - "couldn't find module '" + module + "'"); + "couldn't find module '" + module + "'"); } - try { + try + { java.net.URLConnection con = url.openConnection(); - if (con instanceof java.net.JarURLConnection) { + 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(); - while (e.hasMoreElements()) { + String sStartModule = "/" + module + "/"; + while (e.hasMoreElements()) + { String entry = e.nextElement().toString(); @@ -466,49 +594,51 @@ public class APIDescGetter extends DescGetter { // System.out.println("### Read from connetion: " + entry); // } - if ((entry.lastIndexOf("/" + module + "/") != -1) && - entry.endsWith("." + shortName.trim() + ".csv")) { - InputStream input = this.getClass() - .getResourceAsStream("/" + - entry); - csvFile = new BufferedReader( - new InputStreamReader(input)); - + if ((entry.lastIndexOf(sStartModule) != -1) && + entry.endsWith(sEndsWithCSVName)) + { + InputStream input = this.getClass().getResourceAsStream("/" + entry); + csvFile = new BufferedReader(new InputStreamReader(input)); break; } } - } else { + } + else + { InputStream in = con.getInputStream(); - java.io.BufferedReader buf = new java.io.BufferedReader( - new InputStreamReader(in)); + java.io.BufferedReader buf = new java.io.BufferedReader(new InputStreamReader(in)); boolean found = false; - while (buf.ready() && !found) { + while (buf.ready() && !found) + { String entry = buf.readLine(); - if (entry.endsWith(shortName.trim() + ".csv")) { + if (entry.endsWith(sEndsWithCSVName)) + { System.out.println("FOUND ####"); - InputStream input = this.getClass() - .getResourceAsStream("/objdsc/" + - module + - "/" + - entry); + InputStream input = this.getClass().getResourceAsStream("/objdsc/" + + module + + "/" + + entry); csvFile = new BufferedReader( - new InputStreamReader(input)); + new InputStreamReader(input)); found = true; } } buf.close(); } - } catch (java.io.IOException e) { + } + catch (java.io.IOException e) + { e.printStackTrace(); } - if (csvFile == null) { + if (csvFile == null) + { return setErrorDescription(theEntry, - "couldn't find component '" + - theEntry.entryName + "'"); + "couldn't find component '" + + theEntry.entryName + "'"); } DescEntry[] subEntries = getSubEntries(csvFile, theEntry, debug); @@ -520,10 +650,12 @@ public class APIDescGetter extends DescGetter { } protected static DescEntry getFromDirectory(String descPath, String entry, - boolean debug) { + boolean debug) + { int dotindex = entry.indexOf('.'); - if (dotindex == -1) { + if (dotindex == -1) + { return null; } @@ -531,10 +663,13 @@ public class APIDescGetter extends DescGetter { String module = null; String shortName = null; - if (entry.indexOf(".uno") == -1) { + if (entry.indexOf(".uno") == -1) + { module = entry.substring(0, entry.indexOf('.')); shortName = entry.substring(entry.indexOf('.') + 1); - } else { + } + else + { module = entry.substring(0, entry.lastIndexOf('.')); shortName = entry.substring(entry.lastIndexOf('.') + 1); } @@ -546,7 +681,8 @@ public class APIDescGetter extends DescGetter { aEntry.EntryType = "component"; aEntry.isToTest = true; - if (debug) { + if (debug) + { System.out.println("Parsing Description Path: " + descPath); System.out.println("Searching module: " + module); System.out.println("For the Component " + shortName); @@ -554,34 +690,41 @@ public class APIDescGetter extends DescGetter { File modPath = new File(descPath + fs + module); - if (!modPath.exists()) { + if (!modPath.exists()) + { return setErrorDescription(aEntry, - "couldn't find module '" + module + "'"); + "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")) { + 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")) { + if (found.equals("none")) + { return setErrorDescription(aEntry, - "couldn't find component '" + entry + "'"); + "couldn't find component '" + entry + "'"); } String aUrl = descPath + fs + module + fs + found; BufferedReader csvFile = null; - try { + try + { csvFile = new BufferedReader(new FileReader(aUrl)); - } catch (java.io.FileNotFoundException fnfe) { + } + catch (java.io.FileNotFoundException fnfe) + { return setErrorDescription(aEntry, "couldn't find file '" + aUrl + "'"); } @@ -593,14 +736,17 @@ public class APIDescGetter extends DescGetter { return aEntry; } - protected ArrayList getSubInterfaces(String job) { + protected ArrayList getSubInterfaces(String job) + { ArrayList namesList = new ArrayList(); StringTokenizer st = new StringTokenizer(job, ","); - for (int i = 0; st.hasMoreTokens(); i++) { + for (int i = 0; st.hasMoreTokens(); i++) + { String token = st.nextToken(); - if (token.indexOf(".") < 0) { + if (token.indexOf(".") < 0) + { namesList.add(token); } } @@ -608,11 +754,13 @@ public class APIDescGetter extends DescGetter { return namesList; } - protected ArrayList getSubObjects(String job) { + protected ArrayList getSubObjects(String job) + { ArrayList namesList = new ArrayList(); StringTokenizer st = new StringTokenizer(job, ","); - for (int i = 0; st.hasMoreTokens(); i++) { + for (int i = 0; st.hasMoreTokens(); i++) + { namesList.add(st.nextToken()); } @@ -620,17 +768,23 @@ public class APIDescGetter extends DescGetter { } protected String[] createScenario(String descPath, String job, - boolean debug) { + boolean debug) + { String[] scenario = null; - if (descPath != null) { - if (debug) { + if (descPath != null) + { + if (debug) + { System.out.println("## reading from File " + descPath); } scenario = getScenarioFromDirectory(descPath, job, debug); - } else { - if (debug) { + } + else + { + if (debug) + { System.out.println("## reading from jar"); } @@ -641,31 +795,46 @@ public class APIDescGetter extends DescGetter { } protected String[] getScenarioFromDirectory(String descPath, String job, - boolean debug) { + boolean debug) + { String[] modules = null; ArrayList componentList = new ArrayList(); - if (!job.equals("unknown") && !job.equals("listall")) { - modules = new String[] { job }; - } else { + if (!job.equals("unknown") && !job.equals("listall")) + { + modules = new String[] + { + job + }; + } + else + { File dirs = new File(descPath); - if (!dirs.exists()) { + if (!dirs.exists()) + { modules = null; - } else { + } + else + { modules = dirs.list(); } } - for (int i=0;i Output of getModules:"); log.println(procHdl.getOutputText()); log.println("<--- Output of getModules"); @@ -79,33 +88,44 @@ public class CwsDataExchangeImpl implements CwsDataExchange { final String[] outs = procHdl.getOutputText().split("\n"); final ArrayList moduleNames = new ArrayList(); - boolean start = false; - for (int i = 0; i < outs.length; i++) { + boolean bStart = false; + for (int i = 0; i < outs.length; i++) + { final String line = outs[i]; - if (line.startsWith("cwstouched ends here")) { - start = false; + if (line.startsWith("cwstouched starts here")) + { + bStart = true; + continue; } - if (start && line.length() > 1) { - moduleNames.add(line); + if (line.startsWith("cwstouched ends here")) + { + bStart = false; + continue; } - if (line.startsWith("cwstouched starts here")) { - start = true; + if (bStart && line.length() > 1) + { + moduleNames.add(line); } } return moduleNames; } - public void setUnoApiCwsStatus(boolean status) { + public void setUnoApiCwsStatus(boolean status) + { FileWriter out = null; String statusFile = null; - try { + 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"; + statusFile = utils.getUsersTempDir() + + System.getProperty("file.separator") + + "UnoApiCwsStatus." + + (String) param.get(PropertyName.VERSION) + + "_" + param.get(PropertyName.OPERATING_SYSTEM) + stat + ".txt"; out = new FileWriter(statusFile); @@ -113,16 +133,26 @@ public class CwsDataExchangeImpl implements CwsDataExchange { out.flush(); out.close(); - final String[] commands = {"cwsattach " + statusFile}; + final String[] commands = + { + "cwsattach " + statusFile + }; bet.runCommandsInEnvironmentShell(commands, null, 5000); - } catch (IOException ex) { + } + catch (IOException ex) + { System.out.println("ERROR: could not attach file '" + statusFile + "' to cws\n" + ex.toString()); - } finally { - try { + } + finally + { + try + { out.close(); - } catch (IOException ex) { + } + catch (IOException ex) + { ex.printStackTrace(); } } diff --git a/qadevOOo/runner/helper/ProcessHandler.java b/qadevOOo/runner/helper/ProcessHandler.java index 9939a73bf215..859f00a55593 100644 --- a/qadevOOo/runner/helper/ProcessHandler.java +++ b/qadevOOo/runner/helper/ProcessHandler.java @@ -366,17 +366,20 @@ public class ProcessHandler { ow = (OfficeWatcher) param.get(PropertyName.OFFICE_WATCHER); } + if (ow != null) + { + ow.ping(); + } + int hangcheck = 10; while (!this.isFinished() && changedText) { count++; - if (ow != null) - { - ow.ping(); - } - dbg("runCommand: waiting " + mTimeOut / 1000 + " seconds while command execution is ongoing... " + count); - shortWait(mTimeOut); + // 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) { @@ -385,13 +388,18 @@ public class ProcessHandler // check for changes in the output stream. If there are no changes, the process maybe hangs if (!this.isFinished()) { - if (this.getOutputText().length() == memText.length()) + hangcheck--; + if (hangcheck < 0) { - changedText = false; - dbg("runCommand Could not detect changes in output stream!!!"); - + String sOutputText = getOutputText(); + if (sOutputText.length() == memText.length()) + { + changedText = false; + // dbg("runCommand Could not detect changes in output stream!!!"); + } + hangcheck = 10; + memText = this.getOutputText(); } - memText = this.getOutputText(); } } @@ -539,9 +547,6 @@ public class ProcessHandler 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(); @@ -578,7 +583,12 @@ public class ProcessHandler * @return true if process correctly exited * (exit code doesn't affect to this result). */ - public boolean waitFor(long timeout) + public boolean waitFor(long timeout) + { + return waitFor(timeout, true); + } + + private boolean waitFor(long timeout, boolean bKillProcessAfterTimeout) { if (isFinished()) { @@ -638,11 +648,14 @@ public class ProcessHandler } } - if (!isFinished) + if (bKillProcessAfterTimeout == true) { - log.println("Going to destroy the process!!"); - m_aProcess.destroy(); - log.println("Process has been destroyed!"); + 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 { diff --git a/qadevOOo/runner/lib/MultiMethodTest.java b/qadevOOo/runner/lib/MultiMethodTest.java index 2ebac0b3675d..a33331967681 100644 --- a/qadevOOo/runner/lib/MultiMethodTest.java +++ b/qadevOOo/runner/lib/MultiMethodTest.java @@ -27,7 +27,6 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ - package lib; import java.io.PrintWriter; @@ -43,7 +42,6 @@ import share.DescEntry; import lib.TestParameters; import stats.Summarizer; - /** * The class supports method based interface tests development. * @@ -81,38 +79,34 @@ import stats.Summarizer; * * @see TestResult */ -public class MultiMethodTest { +public class MultiMethodTest +{ /** * Contains the TestEnvironment being tested, to allow for tests to access * it. */ protected TestEnvironment tEnv; - /** * Contains the TestParameters for the tests, to allow for tests to access * it. */ protected TestParameters tParam; - /** * Contains the Description for the test * it. */ protected DescEntry entry; - /** * Contains a writer to log an information about the interface testing, to * allows for tests to access it. */ protected PrintWriter log; - /** * Contains the TestResult instance for the interface test to collect * information about methods test. */ protected TestResult tRes; - /** * Contains names of the methods have been alreadycalled */ @@ -123,7 +117,8 @@ public class MultiMethodTest { * * @param tEnv the environment to dispose */ - public void disposeEnvironment( TestEnvironment tEnv ) { + public void disposeEnvironment(TestEnvironment tEnv) + { disposeEnvironment(); } @@ -132,10 +127,11 @@ public class MultiMethodTest { * * @see #disposeEnvironment(TestEnvironment) */ - public void disposeEnvironment() { + public void disposeEnvironment() + { tEnv.dispose(); TestCase tCase = tEnv.getTestCase(); - tCase.disposeTestEnvironment( tEnv, tParam ); + tCase.disposeTestEnvironment(tEnv, tParam); } /** @@ -147,92 +143,113 @@ public class MultiMethodTest { * called. After them, after() method is called, to allow cleaning up the * stuff initialized in before() and test methods. * + * @param entry the interface test state * @param tEnv the environment to test - * @param ifcState the interface test state * @param tParam the parameters of the test * * @see #before * @see #after */ - public TestResult run( DescEntry entry, TestEnvironment tEnv, TestParameters tParam ) { + public TestResult run(DescEntry entry, TestEnvironment tEnv, TestParameters tParam) + { log = (PrintWriter) entry.Logger; this.tEnv = tEnv; this.tParam = tParam; - this.log = log; + // this.log = log; this.entry = entry; this.tRes = new TestResult(); Class testedClass; - String ifcName = getInterfaceName(); - System.out.println("checking : "+ifcName); + // Some fake code for a self test. + // For normal test we must not be a "ifc.qadevooo._SelfTest" + if (! entry.entryName.equals("ifc.qadevooo._SelfTest")) + { + String ifcName = getInterfaceName(); + System.out.println("checking : " + ifcName); - // defining a name of the class corresponding to the tested interface - // or service - String testedClassName; + // defining a name of the class corresponding to the tested interface + // or service + String testedClassName; - testedClassName = getTestedClassName(); - - if (entry.EntryType.equals("service")) { - testedClassName = "com.sun.star.beans.XPropertySet"; - } + testedClassName = getTestedClassName(); - try { - testedClass = Class.forName(testedClassName); - } catch (ClassNotFoundException cnfE) { + if (entry.EntryType.equals("service")) + { + testedClassName = "com.sun.star.beans.XPropertySet"; + } - cnfE.printStackTrace(log); - log.println("could not find a class : " + getTestedClassName()); - return null; + try + { + testedClass = Class.forName(testedClassName); + } + catch (ClassNotFoundException cnfE) + { - } + cnfE.printStackTrace(log); + log.println("could not find a class : " + getTestedClassName()); + return null; - // quering the tested interface from the tested object - XInterface tCase = tEnv.getTestObject(); - Object oObj = UnoRuntime.queryInterface( - testedClass, tEnv.getTestObject()); - - if (oObj == null) { - if (entry.isOptional) { - Summarizer.summarizeDown( - entry,"Not supported but optional.OK"); - } else { - Summarizer.summarizeDown( - entry,"queryInterface returned null.FAILED"); - entry.ErrorMsg="queryInterface returned null"; - entry.hasErrorMsg=true; } - return null; - } + // quering the tested interface from the tested object + XInterface tCase = tEnv.getTestObject(); + Object oObj = UnoRuntime.queryInterface(testedClass, tEnv.getTestObject()); + + if (oObj == null) + { + if (entry.isOptional) + { + Summarizer.summarizeDown(entry, "Not supported but optional.OK"); + } + else + { + Summarizer.summarizeDown(entry, "queryInterface returned null.FAILED"); + entry.ErrorMsg = "queryInterface returned null"; + entry.hasErrorMsg = true; + } - //setting the field oObj - setField("oObj",oObj); + return null; + } + //setting the field oObj + setField("oObj", oObj); + } // to perform some stuff before all method tests - try { + try + { before(); - } catch (Exception e){ + } + catch (Exception e) + { setSubStates(e.toString()); return tRes; } // executing methods tests - for (int i=0;i-1) { + if (entry.longName.indexOf("::drafts::com::") > -1) + { append = "drafts.com.sun.star."; } - return append - + clsName.substring(firstDot + 1, lastDot + 1) - + clsName.substring(lastDot + 2); + return append + clsName.substring(firstDot + 1, lastDot + 1) + clsName.substring(lastDot + 2); } /** @@ -278,18 +296,22 @@ public class MultiMethodTest { * @param methName the method name to set status * @param methStatus the status to set to the method */ - protected void setStatus( String methName, Status methStatus ) { - tRes.tested( methName, methStatus ); + protected void setStatus(String methName, Status methStatus) + { + tRes.tested(methName, methStatus); } /** * sets the substates */ - protected void setSubStates(String msg) { - for (int k=0;kmethod is optional in the service. */ - protected boolean isOptional(String method) { - for (int k=0;kmethod test has been already called. */ - protected boolean isCalled( String method ) { - return methCalled.contains( method ); + protected boolean isCalled(String method) + { + return methCalled.contains(method); } /** @@ -320,15 +346,16 @@ public class MultiMethodTest { * be called. The method checks this and if it is not called, calls it. * If the method is failed or skipped, it throws StatusException. */ - protected void requiredMethod(String method) { + protected void requiredMethod(String method) + { log.println("starting required method: " + method); - executeMethod( method ); - Status mtStatus = tRes.getStatusFor( method ); + executeMethod(method); + Status mtStatus = tRes.getStatusFor(method); - if ( mtStatus != null - && (!mtStatus.isPassed() || mtStatus.isFailed()) ) { - log.println( "! Required method " + method + " failed" ); - throw new StatusException( mtStatus ); + if (mtStatus != null && (!mtStatus.isPassed() || mtStatus.isFailed())) + { + log.println("! Required method " + method + " failed"); + throw new StatusException(mtStatus); } } @@ -336,10 +363,12 @@ public class MultiMethodTest { * Checks if the method was called, and if not, call it. * On contrary to requiredMethod(), he method doesn't check its status. */ - protected void executeMethod( String method ) { - if ( ! isCalled( method ) ) { - log.println("Execute: "+ method); - callMethod( method ); + protected void executeMethod(String method) + { + if (!isCalled(method)) + { + log.println("Execute: " + method); + callMethod(method); log.println(method + ": " + tRes.getStatusFor(method)); } } @@ -347,7 +376,8 @@ public class MultiMethodTest { /** * Just calls the method test. */ - protected void callMethod(String method) { + protected void callMethod(String method) + { methCalled.add(method); invokeTestMethod(getMethodFor(method), method); } @@ -359,31 +389,47 @@ public class MultiMethodTest { * @param meth the subclass' method to invoke * @param methName the name of the method */ - protected void invokeTestMethod(Method meth, String methName) { - if (meth == null) { - setStatus( methName, Status.skipped( false ) ); - } else { + protected void invokeTestMethod(Method meth, String methName) + { + if (meth == null) + { + setStatus(methName, Status.skipped(false)); + } + else + { Status stat; - try { + try + { meth.invoke(this, new Object[0]); return; - } catch (InvocationTargetException itE) { + } + catch (InvocationTargetException itE) + { Throwable t = itE.getTargetException(); - if ( t instanceof StatusException ) { - stat = ((StatusException)t).getStatus(); - } else { + if (t instanceof StatusException) + { + stat = ((StatusException) t).getStatus(); + } + else + { t.printStackTrace(log); stat = Status.exception(t); } - } catch (IllegalAccessException iaE) { + } + catch (IllegalAccessException iaE) + { iaE.printStackTrace(log); stat = Status.exception(iaE); - } catch (IllegalArgumentException iaE) { + } + catch (IllegalArgumentException iaE) + { iaE.printStackTrace(log); stat = Status.exception(iaE); - } catch (ClassCastException ccE) { + } + catch (ClassCastException ccE) + { ccE.printStackTrace(log); stat = Status.exception(ccE); } @@ -397,18 +443,23 @@ public class MultiMethodTest { * * @return the testing method, if found, null otherwise */ - protected Method getMethodFor(String method) { + protected Method getMethodFor(String method) + { String mName = "_" + method; - if (mName.endsWith("()")) { + if (mName.endsWith("()")) + { mName = mName.substring(0, mName.length() - 2); } final Class[] paramTypes = new Class[0]; - try { + try + { return this.getClass().getDeclaredMethod(mName, paramTypes); - } catch (NoSuchMethodException nsmE) { + } + catch (NoSuchMethodException nsmE) + { return null; } } @@ -416,38 +467,43 @@ public class MultiMethodTest { /** * @return the name of the interface tested */ - public String getInterfaceName() { + public String getInterfaceName() + { String clName = this.getClass().getName(); - return clName.substring( clName.lastIndexOf('.') + 1 ); + return clName.substring(clName.lastIndexOf('.') + 1); } - /** * Initializes fieldName of the subclass with * value. * * @return Status describing the result of the operation. */ - protected Status setField( String fieldName, Object value) { + protected Status setField(String fieldName, Object value) + { Field objField; - try { - objField = this.getClass().getField( fieldName ); + try + { + objField = this.getClass().getField(fieldName); } - catch( NoSuchFieldException nsfE ){ - return Status.exception( nsfE ); + catch (NoSuchFieldException nsfE) + { + return Status.exception(nsfE); } - try { - objField.set( this, value ); + try + { + objField.set(this, value); return Status.passed(true); } - catch( IllegalArgumentException iaE ){ - return Status.exception( iaE ); + catch (IllegalArgumentException iaE) + { + return Status.exception(iaE); } - catch( IllegalAccessException iaE ){ - return Status.exception( iaE ); + catch (IllegalAccessException iaE) + { + return Status.exception(iaE); } } - } diff --git a/qadevOOo/runner/share/DescGetter.java b/qadevOOo/runner/share/DescGetter.java index 3b038e5ab090..dc6ac351ccb1 100644 --- a/qadevOOo/runner/share/DescGetter.java +++ b/qadevOOo/runner/share/DescGetter.java @@ -36,62 +36,76 @@ import java.util.StringTokenizer; import java.util.Vector; - /** * * Base Interface to get a description for a given TestJob * */ -public abstract class DescGetter { +public abstract class DescGetter +{ + public abstract DescEntry[] getDescriptionFor(String entry, - String DescPath, - boolean debug); + String DescPath, + boolean debug); protected abstract DescEntry getDescriptionForSingleJob(String job, - String descPath, - boolean debug); + String descPath, + boolean debug); protected abstract String[] createScenario(String descPath, String job, - boolean debug); + boolean debug); protected DescEntry[] getScenario(String url, String descPath, - boolean debug) { + boolean debug) + { Vector entryList = new Vector(); String line = ""; BufferedReader scenario = null; DescEntry[] entries = null; - try { + try + { scenario = new BufferedReader(new FileReader(url)); - } catch (java.io.FileNotFoundException fnfe) { + } + catch (java.io.FileNotFoundException fnfe) + { System.out.println("Couldn't find file " + url); return entries; } - while (line != null) { - try { - if (line.startsWith("-o")) { + while (line != null) + { + try + { + if (line.startsWith("-o")) + { String job = line.substring(3, line.length()).trim(); - DescEntry aEntry ; + DescEntry aEntry; // special in case several Interfaces are given comma separated - if (job.indexOf(",") < 0) { + if (job.indexOf(",") < 0) + { aEntry = getDescriptionForSingleJob(job, descPath, - debug); - } else { + debug); + } + else + { ArrayList subs = getSubInterfaces(job); String partjob = job.substring(0, job.indexOf(",")).trim(); aEntry = getDescriptionForSingleJob(partjob, descPath, - debug); + debug); - if (aEntry != null) { - for (int i = 0; i < aEntry.SubEntryCount; i++) { + if (aEntry != null) + { + for (int i = 0; i < aEntry.SubEntryCount; i++) + { String subEntry = aEntry.SubEntries[i].longName; int cpLength = aEntry.longName.length(); subEntry = subEntry.substring(cpLength + 2, - subEntry.length()); + subEntry.length()); - if (subs.contains(subEntry)) { + if (subs.contains(subEntry)) + { aEntry.SubEntries[i].isToTest = true; } } @@ -101,63 +115,82 @@ public abstract class DescGetter { // line.substring(3).trim(), descPath, // debug); if (aEntry != null) + { entryList.add(aEntry); - } else if (line.startsWith("-sce")) { + } + } + else if (line.startsWith("-sce")) + { DescEntry[] subs = getScenario(line.substring(5, - line.length()) - .trim(), descPath, - debug); + line.length()).trim(), descPath, + debug); - for (int i = 0; i < subs.length; i++) { + for (int i = 0; i < subs.length; i++) + { entryList.add(subs[i]); } - } else if (line.startsWith("-p")) { + } + else if (line.startsWith("-p")) + { String[] perModule = createScenario(descPath, - line.substring(3) - .trim(), debug); + line.substring(3).trim(), debug); - for (int i = 0; i < perModule.length; i++) { + for (int i = 0; i < perModule.length; i++) + { DescEntry aEntry = getDescriptionForSingleJob( - perModule[i].substring(3) - .trim(), - descPath, debug); + perModule[i].substring(3).trim(), + descPath, debug); if (aEntry != null) + { entryList.add(aEntry); + } } } line = scenario.readLine(); - } catch (java.io.IOException ioe) { - if (debug) { + } + catch (java.io.IOException ioe) + { + if (debug) + { System.out.println("Exception while reading scenario"); } } } - try { + try + { scenario.close(); - } catch (java.io.IOException ioe) { - if (debug) { + } + catch (java.io.IOException ioe) + { + if (debug) + { System.out.println("Exception while closeing scenario"); } } if (entryList.size() == 0) + { return null; + } entries = new DescEntry[entryList.size()]; entries = (DescEntry[]) entryList.toArray(entries); return entries; } - protected ArrayList getSubInterfaces(String job) { + protected ArrayList getSubInterfaces(String job) + { ArrayList namesList = new ArrayList(); StringTokenizer st = new StringTokenizer(job, ","); - for (int i = 0; st.hasMoreTokens(); i++) { + for (int i = 0; st.hasMoreTokens(); i++) + { String token = st.nextToken(); - if (token.indexOf(".") < 0) { + if (token.indexOf(".") < 0) + { namesList.add(token); } } diff --git a/qadevOOo/runner/util/DesktopTools.java b/qadevOOo/runner/util/DesktopTools.java index 104bcdc309d3..ec62745ac4df 100644 --- a/qadevOOo/runner/util/DesktopTools.java +++ b/qadevOOo/runner/util/DesktopTools.java @@ -429,7 +429,7 @@ public class DesktopTools { * @param xModel the XModel of the document to bring to top */ public static void bringWindowToFront(XModel xModel){ - System.out.println("DEBUG: bring to front xModel"); + // System.out.println("DEBUG: bring to front xModel"); XTopWindow xTopWindow = (XTopWindow) UnoRuntime.queryInterface( @@ -440,7 +440,7 @@ public class DesktopTools { } public static void bringWindowToFront(XComponent xComponent){ - System.out.println("DEBUG: bring to front xComponent"); + // System.out.println("DEBUG: bring to front xComponent"); XModel xModel = (XModel) UnoRuntime.queryInterface(XModel.class, xComponent); if (xModel != null){ bringWindowToFront(xModel); diff --git a/qadevOOo/tests/java/complex/unoapi/CheckModuleAPI.java b/qadevOOo/tests/java/complex/unoapi/CheckModuleAPI.java index 4ca0728de864..20b36a057757 100644 --- a/qadevOOo/tests/java/complex/unoapi/CheckModuleAPI.java +++ b/qadevOOo/tests/java/complex/unoapi/CheckModuleAPI.java @@ -44,7 +44,7 @@ import helper.BuildEnvTools; import helper.ComplexDescGetter; import helper.CwsDataExchangeImpl; import java.io.File; -import java.io.FileFilter; +// import java.io.FileFilter; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; @@ -70,7 +70,8 @@ import util.utils; * * */ -public class CheckModuleAPI extends ComplexTestCase { +public class CheckModuleAPI extends ComplexTestCase +{ private static String mSRC_ROOT = null; private static boolean mIsInitialized = false; @@ -87,16 +88,21 @@ public class CheckModuleAPI extends ComplexTestCase { * but this will take some time. * Note: This funktionality is only reasonable with parameter -noOffice true */ - public void before() { + public void before() + { - if (!mIsInitialized) { + if (!mIsInitialized) + { mIsInitialized = true; - try { + try + { bet = new BuildEnvTools(param, log); - } catch (ParameterNotFoundException ex) { + } + catch (ParameterNotFoundException ex) + { this.failed(ex.toString(), false); } @@ -111,11 +117,15 @@ public class CheckModuleAPI extends ComplexTestCase { * let API tests run. * @param module */ - public void checkModule(String module) { + public void checkModule(String module) + { log.println(utils.getDateTime() + ": start testing module '" + module + "'"); log.println(utils.getDateTime() + "start new Office instance..."); + + // TODO: is Office started with this program? final OfficeProvider officeProvider = new OfficeProvider(); + log.println(utils.getDateTime() + "Receiving the ServiceManager of the Office "); final XMultiServiceFactory msf = (XMultiServiceFactory) officeProvider.getManager(param); assure("couldnot get ServiceFarcotry", msf != null, mContinue); @@ -128,12 +138,12 @@ public class CheckModuleAPI extends ComplexTestCase { final File fMakeFile = new File(sMakeFile); assure("ERROR: could not find makefile: '" + sMakeFile + "'", fMakeFile.exists(), mContinue); - final String[] commands = getCommands(sUnoapi); + final String[] commands = getDmakeCommands(sUnoapi); final ProcessHandler procHdl = bet.runCommandsInEnvironmentShell(commands, fUnoapi, 0); log.println("exit code of dmake: " + procHdl.getExitCode()); String test = procHdl.getOutputText(); - test = procHdl.getErrorText(); + test += procHdl.getErrorText(); // if (mDebug) { // log.println("---> Output of dmake:"); // log.println(procHdl.getOutputText()); @@ -142,40 +152,93 @@ public class CheckModuleAPI extends ComplexTestCase { // log.println(procHdl.getErrorText()); // log.println("<--- Error output of dmake:"); // } - assure("module '" + module + "' failed", verifyOutput(procHdl.getOutputText()), mContinue); + assure("module '" + module + "' failed", verifyOutput(test), mContinue); log.println(utils.getDateTime() + " module '" + module + "': kill existing office..."); - try { - officeProvider.closeExistingOffice(param, true); - } catch (java.lang.UnsatisfiedLinkError exception) { - log.println("Office seems not to be running"); - } + // TODO: how to check if the office is not started with this process. + boolean bNoOffice = param.getBool("NoOffice"); + if (!bNoOffice) + { + try + { + officeProvider.closeExistingOffice(param, true); + } + catch (java.lang.UnsatisfiedLinkError exception) + { + log.println("Office seems not to be running"); + } + } } - - private void addIfQaUnoApiFolderExist(File srcRoot, ArrayList moduleNames) { - - if (doesQaUnoApiFolderExist(srcRoot)) { - moduleNames.add(srcRoot.getName()); + private String getQaUnoApiPath(String srcRoot, String _sModul) + { + File aFile = new File(srcRoot); + if (!aFile.exists()) + { + System.out.println("ERROR: srcRoot '" + srcRoot + "' does not exist."); + return null; + } + String sModulePath = srcRoot; + sModulePath += File.separator; + sModulePath += _sModul; + + File aModulePath = new File(sModulePath); + if (! aModulePath.exists()) + { + aModulePath = new File(sModulePath + ".lnk"); + if (! aModulePath.exists()) + { + aModulePath = new File(sModulePath + ".link"); + if (! aModulePath.exists()) + { + // module does not exist. + return null; + } + } + } + sModulePath = aModulePath.getAbsolutePath(); + sModulePath += File.separator; + sModulePath += "qa"; + sModulePath += File.separator; + sModulePath += "unoapi"; + File aModulePathQaUnoApi = new File(sModulePath); + if (aModulePathQaUnoApi.exists()) + { + return aModulePathQaUnoApi.getAbsolutePath(); } + return null; } - - private boolean doesQaUnoApiFolderExist(File srcRoot) { + private boolean doesQaUnoApiFolderExist(String srcRoot, String _sModul) + { + if (getQaUnoApiPath(srcRoot, _sModul) != null) + { + return true; + } + return false; + } +/* + private boolean doesQaUnoApiFolderExist(File srcRoot) + { final FolderFilter qaFilter = new FolderFilter("qa"); final File[] qaTree = srcRoot.listFiles(qaFilter); - if (qaTree != null) { - for (int j = 0; j < qaTree.length; j++) { + if (qaTree != null) + { + for (int j = 0; j < qaTree.length; j++) + { final File qaFolder = qaTree[j]; final FolderFilter apiFilter = new FolderFilter("unoapi"); final File[] apiTree = qaFolder.listFiles(apiFilter); - if (apiTree != null && apiTree.length > 0) { + if (apiTree != null && apiTree.length > 0) + { return true; } } } return false; } +*/ - private String[] getAllModuleCommand() { + private String[] getAllModuleCommand() + { String[] checkModules; final String[] names = getModulesFromSourceRoot(); @@ -184,45 +247,75 @@ public class CheckModuleAPI extends ComplexTestCase { return checkModules; } - private String[] getCheckModuleCommand(String[] names) { + private String[] getCheckModuleCommand(String[] names) + { String[] checkModules; checkModules = new String[names.length]; - for (int i = 0; i < names.length; i++) { + for (int i = 0; i < names.length; i++) + { // if a module is not added to a cws it contains a dot in its name (forms.lnk) - if (names[i].indexOf(".") != -1) { + if (names[i].indexOf(".") != -1) + { checkModules[i] = "checkModule(" + names[i].substring(0, names[i].indexOf(".")) + ")"; - } else { + } + else + { checkModules[i] = "checkModule(" + names[i] + ")"; } } return checkModules; } - private String[] getCommands(String sUnoapi) { + private String[] getDmakeCommands(String sUnoapi) + { String[] cmdLines = null; final String platform = (String) param.get(PropertyName.OPERATING_SYSTEM); log.println("prepare command for platform " + platform); - if (platform.equals(PropertyName.WNTMSCI)){ - if (param.getBool(PropertyName.CYGWIN)){ - cmdLines = new String[]{"cd `cygpath '" + sUnoapi.replaceAll("\\\\", "\\\\\\\\")+ "'`", "dmake"}; - } else{ - cmdLines = new String[]{"cdd " + sUnoapi, "dmake"}; + if (platform.equals(PropertyName.WNTMSCI)) + { + if (param.getBool(PropertyName.CYGWIN)) + { + // cygwin stuff + cmdLines = new String[] + { + "cd `cygpath '" + sUnoapi.replaceAll("\\\\", "\\\\\\\\") + "'`", + "dmake" + }; } - } else { - cmdLines = new String[]{"cd " + sUnoapi, "dmake"}; + else + { + // old 4NT + cmdLines = new String[] + { + "cdd " + sUnoapi, + "dmake" + }; } + } + else + { + // unix + cmdLines = new String[] + { + "cd " + sUnoapi, + "dmake" + }; + } return cmdLines; } - private String[] getCwsModuleCommand() { + private String[] getCwsModuleCommand() + { String[] checkModules; final String version = (String) param.get(PropertyName.VERSION); String[] names = null; - if (version.startsWith("cws_")) { - try { + if (version.startsWith("cws_")) + { + try + { // cws version: all added modules must be tested final String cws = version.substring(4, version.length()); final CwsDataExchangeImpl cde = new CwsDataExchangeImpl(cws, param, log); @@ -230,18 +323,27 @@ public class CheckModuleAPI extends ComplexTestCase { final ArrayList moduleNames = new ArrayList(); Iterator iterator = addedModules.iterator(); - while (iterator.hasNext()) { - final File sourceRoot = new File(mSRC_ROOT + File.separator + (String) iterator.next()); - addIfQaUnoApiFolderExist(sourceRoot, moduleNames); - + while (iterator.hasNext()) + { + String sModuleName = (String) iterator.next(); + // String sFilename = mSRC_ROOT; // + File.separator + sModuleName; + // final File sourceRoot = new File(sFilename); + if (doesQaUnoApiFolderExist(mSRC_ROOT, sModuleName)) + { + moduleNames.add(sModuleName); + } } names = (String[]) moduleNames.toArray(new String[0]); - } catch (ParameterNotFoundException ex) { + } + catch (ParameterNotFoundException ex) + { this.failed(ex.toString(), false); } - } else { + } + else + { // major version: all modules must be tested names = getModulesFromSourceRoot(); } @@ -250,53 +352,70 @@ public class CheckModuleAPI extends ComplexTestCase { return checkModules; } - private String[] getDefinedModuleCommand(String module) { + private String[] getDefinedModuleCommand(String module) + { String[] checkModules = null; // list of modules to test: (sw,sc,sd) - if (module.indexOf(",") != -1) { + if (module.indexOf(",") != -1) + { final String[] names = module.split(","); checkModules = new String[names.length]; - for (int i = 0; i < names.length; i++) { + for (int i = 0; i < names.length; i++) + { final String moduleName = names[i].trim(); - File sourceRoot = new File(mSRC_ROOT + File.separator + moduleName); - if (!sourceRoot.exists()) { - sourceRoot = new File(mSRC_ROOT + File.separator + moduleName + ".lnk"); - } +// File sourceRoot = new File(mSRC_ROOT + File.separator + moduleName); +// if (!sourceRoot.exists()) +// { +// sourceRoot = new File(mSRC_ROOT + File.separator + moduleName + ".lnk"); +// } - if (doesQaUnoApiFolderExist(sourceRoot)) { + if (doesQaUnoApiFolderExist(mSRC_ROOT, moduleName)) + { checkModules[i] = "checkModule(" + moduleName + ")"; } } - } else { - File sourceRoot = new File(mSRC_ROOT + File.separator + module); - if (!sourceRoot.exists()) { - sourceRoot = new File(mSRC_ROOT + File.separator + module + ".lnk"); - } - if (doesQaUnoApiFolderExist(sourceRoot)) { - checkModules = new String[]{"checkModule(" + module + ")"}; + } + else + { +// File sourceRoot = new File(mSRC_ROOT + File.separator + module); +// if (!sourceRoot.exists()) +// { +// sourceRoot = new File(mSRC_ROOT + File.separator + module + ".lnk"); +// } + if (doesQaUnoApiFolderExist(mSRC_ROOT, module)) + { + checkModules = new String[] + { + "checkModule(" + module + ")" + }; } } return checkModules; } - private String getModulePath(String module) { - - String sUnoapi = null; - final String sep = System.getProperty("file.separator"); - final File srcRoot = new File(mSRC_ROOT); - - final FolderFilter qaFilter = new FolderFilter(module); - final File[] moduleTree = srcRoot.listFiles(qaFilter); - if (moduleTree != null) { - if (mDebug) { - log.println("moduleTree length:" + moduleTree.length); - log.println("moduleTree: " + moduleTree[0].getAbsolutePath()); - } - if (moduleTree != null) { - sUnoapi = moduleTree[0].getAbsolutePath() + sep + "qa" + sep + "unoapi"; - } - } + private String getModulePath(String module) + { + + // String sUnoapi = null; + // final String sep = System.getProperty("file.separator"); + // final File srcRoot = new File(mSRC_ROOT); + + // final FolderFilter qaFilter = new FolderFilter(module); + // final File[] moduleTree = srcRoot.listFiles(qaFilter); +// if (moduleTree != null) +// { +// if (mDebug) +// { +// log.println("moduleTree length:" + moduleTree.length); +// log.println("moduleTree: " + moduleTree[0].getAbsolutePath()); +// } +// if (moduleTree != null) +// { +// sUnoapi = moduleTree[0].getAbsolutePath() + sep + "qa" + sep + "unoapi"; +// } +// } + String sUnoapi = getQaUnoApiPath(mSRC_ROOT, module); return sUnoapi; } @@ -314,35 +433,39 @@ public class CheckModuleAPI extends ComplexTestCase { * sfx -> sfx2 * sm -> starmath */ - private String getTranslatedNames(String module) { + private String getTranslatedNames(String module) + { - final HashMap modulez = new HashMap(); + final HashMap aModuleHashMap = new HashMap(); - modulez.put("fwk", "framework"); - modulez.put("fwl", "framework"); - modulez.put("sch", "chart2"); - modulez.put("sysmgr1", "configmgr"); - modulez.put("cfgmag2", "configmgr"); - modulez.put("lnn", "lingu"); - modulez.put("lng", "linguistic"); - modulez.put("sfx", "sfx2"); - modulez.put("sm", "starmath"); + aModuleHashMap.put("fwk", "framework"); + aModuleHashMap.put("fwl", "framework"); + aModuleHashMap.put("sch", "chart2"); + aModuleHashMap.put("sysmgr1", "configmgr"); + aModuleHashMap.put("cfgmag2", "configmgr"); + aModuleHashMap.put("lnn", "lingu"); + aModuleHashMap.put("lng", "linguistic"); + aModuleHashMap.put("sfx", "sfx2"); + aModuleHashMap.put("sm", "starmath"); // it could the that the parameter looks like "fwk,fwl". This results in double "famework,framework". // The following loop correct this to only one "framework" - final Set keys = modulez.keySet(); + final Set keys = aModuleHashMap.keySet(); final Iterator iterator = keys.iterator(); - while (iterator.hasNext()) { + while (iterator.hasNext()) + { final String key = (String) iterator.next(); - final String value = (String) modulez.get(key); + final String value = (String) aModuleHashMap.get(key); module = module.replaceAll(key, value); final int count = module.split(value).length; - if (count > 2) { - for (int i = 2; i < count; i++) { + if (count > 2) + { + for (int i = 2; i < count; i++) + { module.replaceFirst("," + value, ""); } @@ -351,33 +474,41 @@ public class CheckModuleAPI extends ComplexTestCase { return module; } - private boolean verifyOutput(String output) { + private boolean verifyOutput(String output) + { log.println("verify output..."); boolean ok = false; final String[] outs = output.split("\n"); - for (int i = 0; i < outs.length; i++) { + for (int i = 0; i < outs.length; i++) + { final String line = outs[i]; - if (line.matches("[0-9]+? of [0-9]+? tests failed")) { + if (line.matches("[0-9]+? of [0-9]+? tests failed")) + { log.println("mached line: " + line); - if (line.matches("0 of [0-9]+? tests failed")) { + if (line.matches("0 of [0-9]+? tests failed")) + { ok = true; log.println("Module passed OK"); - } else { + } + else + { log.println("Module passed FAILED"); } } } - if (!ok) { + if (!ok) + { log.println("ERROR: could not find '0 of [0-9]+? tests failed' in output"); } return ok; } - private String[] getModulesFromSourceRoot() { + private String[] getModulesFromSourceRoot() + { log.println("**** run module tests over all modules ****"); log.println("search for qa/unoapi foldres in all modules based in "); @@ -387,11 +518,17 @@ public class CheckModuleAPI extends ComplexTestCase { final File sourceRoot = new File(mSRC_ROOT); final File[] sourceTree = sourceRoot.listFiles(); - assure("Could not find any files in SOURCE_ROOT=" + mSRC_ROOT, sourceTree != null, false); +// assure("Could not find any files in SOURCE_ROOT=" + mSRC_ROOT, sourceTree != null, false); - for (int i = 0; i < sourceTree.length; i++) { + for (int i = 0; i < sourceTree.length; i++) + { final File moduleName = sourceTree[i]; - addIfQaUnoApiFolderExist(moduleName, moduleNames); + String sModuleName = moduleName.getName(); // (String)moduleNames.get(i); + if (doesQaUnoApiFolderExist(mSRC_ROOT, sModuleName)) + { + // addIfQaUnoApiFolderExist(moduleName, moduleNames); + moduleNames.add(sModuleName); + } } final String[] names = (String[]) moduleNames.toArray(new String[0]); @@ -409,7 +546,8 @@ public class CheckModuleAPI extends ComplexTestCase { *
  • 'auto' to check only modules which are added to the ChildWorkSpace
  • * */ - public void module(String module) { + public void module(String module) + { String[] checkModules; final ComplexDescGetter desc = new ComplexDescGetter(); @@ -420,30 +558,38 @@ public class CheckModuleAPI extends ComplexTestCase { all: check all modules which contains a qa/unoapi folder auto: check all modules which contains a qa/unoapi folder except the module is not added */ - if (module.equals("all")) { + if (module.equals("all")) + { checkModules = getAllModuleCommand(); - } else if (module.equals("auto")) { + } + else if (module.equals("auto")) + { checkModules = getCwsModuleCommand(); - } else { + } + else + { module = getTranslatedNames(module); checkModules = getDefinedModuleCommand(module); } - if (checkModules != null && checkModules.length > 0) { + if (checkModules != null && checkModules.length > 0) + { entry = desc.createTestDesc("complex.unoapi.CheckModuleAPI", "complex.unoapi.CheckModuleAPI", checkModules, - log); + log); final java_complex complex = new java_complex(); log.println("********** start test *************"); - final boolean result = complex.executeTest(param, new DescEntry[]{entry}); + final boolean result = complex.executeTest(param, new DescEntry[] { entry }); log.println("********** end test *************"); assure("CheckModuleAPI.module(" + module + ") PASSED.FAILED", result); - } else { - log.println("No modules containing qa/unoapi foder found => OK"); + } + else + { + log.println("No modules containing qa/unoapi folder found => OK"); state = true; } @@ -451,48 +597,65 @@ public class CheckModuleAPI extends ComplexTestCase { } - private void setUnoApiCwsStatus(boolean status) { + private void setUnoApiCwsStatus(boolean status) + { - if (!param.getBool(PropertyName.NO_CWS_ATTACH)) { + if (!param.getBool(PropertyName.NO_CWS_ATTACH)) + { final String version = (String) param.get(PropertyName.VERSION); - if (version.startsWith("cws_")) { - try { + if (version.startsWith("cws_")) + { + try + { // cws version: all added modules must be tested final String cws = version.substring(4, version.length()); final CwsDataExchangeImpl cde = new CwsDataExchangeImpl(cws, param, log); cde.setUnoApiCwsStatus(status); - } catch (ParameterNotFoundException ex) { + } + catch (ParameterNotFoundException ex) + { log.println("ERROR: could not wirte status to EIS database: " + ex.toString()); } } } } - public String[] getTestMethodNames() { - return new String[]{"module(all)"}; + public String[] getTestMethodNames() + { + return new String[] + { + "module(all)" + }; } - class FolderFilter implements FileFilter { - - private String mFolderName; - - public FolderFilter(String folderName) { - mFolderName = folderName; - } - - public boolean accept(File pathname) { - - boolean found = false; - if (pathname.isDirectory()) { - if (pathname.getName().equals(mFolderName)) { - found = true; - } else if (pathname.getName().equals(mFolderName + ".lnk")) { - found = true; - } - } - return found; - } - } +// class _FolderFilter implements FileFilter +// { +// +// private String mFolderName; +// +// public FolderFilter(String folderName) +// { +// mFolderName = folderName; +// } +// +// public boolean accept_(File pathname) +// { +// +// boolean found = false; +// if (pathname.isDirectory()) +// { +// if (pathname.getName().equals(mFolderName)) +// { +// found = true; +// } +// else if (pathname.getName().equals(mFolderName + ".lnk")) +// { +// found = true; +// } +// } +// return found; +// } +// } } diff --git a/qadevOOo/tests/java/ifc/qadevooo/_SelfTest.java b/qadevOOo/tests/java/ifc/qadevooo/_SelfTest.java new file mode 100755 index 000000000000..e7d215e5bcbb --- /dev/null +++ b/qadevOOo/tests/java/ifc/qadevooo/_SelfTest.java @@ -0,0 +1,86 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: _XActiveDataSource.java,v $ + * $Revision: 1.5 $ + * + * 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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.qadevooo; + +import lib.MultiMethodTest; + +// import com.sun.star.uno.UnoRuntime; +// import com.sun.star.uno.XInterface; + +/** +* Testing ifc.qadevooo._SelfTest +* interface methods: +*
      +*
    • testmethod()
    • +*

    +* +*/ +public class _SelfTest extends MultiMethodTest +{ + + /** + */ + public void before() + { + log.println("_SelfTest.before()"); + } + + /** + * Test calls the method + */ + public void _testmethod() + { + log.println("_SelfTest._testmethod()"); + tRes.tested("testmethod()", true); + } + + public void _testmethod2() + { + log.println("_SelfTest._testmethod2()"); + tRes.tested("testmethod2()", true); + } + + public void _testmethod3() + { + log.println("_SelfTest._testmethod3()"); + tRes.tested("testmethod3()", true); + } + + /** + * Forces object environment recreation. + */ + public void after() + { + log.println("_SelfTest.after()"); + this.disposeEnvironment() ; + } +} + diff --git a/qadevOOo/tests/java/mod/_qadevOOo/SelfTest.java b/qadevOOo/tests/java/mod/_qadevOOo/SelfTest.java new file mode 100755 index 000000000000..6d14de54f8e9 --- /dev/null +++ b/qadevOOo/tests/java/mod/_qadevOOo/SelfTest.java @@ -0,0 +1,95 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ScDocumentConfiguration.java,v $ + * $Revision: 1.5 $ + * + * 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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package mod._qadevOOo; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import util.SOfficeFactory; + +import com.sun.star.text.XSimpleText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; + +public class SelfTest extends TestCase +{ + private XTextDocument xTextDoc = null; + + protected void initialize(TestParameters tParam, PrintWriter log) + { + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory((XMultiServiceFactory) tParam.getMSF()); + + log.println("initialize the selftest"); + try + { + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } + catch (com.sun.star.uno.Exception e) + { + e.printStackTrace(log); + throw new StatusException("Couldn't create document", e); + } + } + + /** + * Disposes text document. + */ + protected void cleanup(TestParameters tParam, PrintWriter log) + { + log.println(" cleanup selftest"); + util.DesktopTools.closeDoc(xTextDoc); + } + + protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) + { + XInterface oObj = null; + log.println("creating a test environment"); + + // get the bodytext of textdocument here + log.println("getting the TextCursor"); + + final XSimpleText aText = xTextDoc.getText(); + final XTextCursor textCursor = aText.createTextCursor(); + oObj = textCursor; + + TestEnvironment tEnv = new TestEnvironment(oObj); + + return tEnv; + } +} -- cgit