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
This commit is contained in:
Vladimir Glazounov
2009-07-06 10:30:52 +00:00
parent 4910706670
commit 91ab2cabe1
16 changed files with 1746 additions and 971 deletions

View File

@@ -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()"
Can't render this file because it contains an unexpected character in line 1 and column 3.

View File

@@ -0,0 +1 @@
# This file contains all Errors

44
qadevOOo/qa/unoapi/makefile.mk Executable file
View File

@@ -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
# <http://www.openoffice.org/license.html>
# 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

View File

@@ -0,0 +1 @@
-o qadevOOo.SelfTest

View File

@@ -59,47 +59,55 @@ import util.DynamicClassLoader;
* *
* this class handles tests written in java and running on a fat Office * 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; private static boolean debug = false;
public static boolean keepdocument = false; private static boolean keepdocument = false;
public static boolean logging = true; private static boolean logging = true;
public static boolean newOffice = false; private static boolean newOffice = false;
private DynamicClassLoader dcl = null; private DynamicClassLoader dcl = null;
public boolean executeTest(lib.TestParameters param) { private lib.TestParameters m_aParams;
dcl = new DynamicClassLoader(); private AppProvider m_aOffice;
DescGetter dg = new APIDescGetter(); public boolean executeTest(lib.TestParameters param)
String job = (String) param.get("TestJob"); {
String ExclusionFile = (String) param.get("ExclusionList"); m_aParams = param;
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);
DescEntry[] entries = dg.getDescriptionFor(job, dcl = new DynamicClassLoader();
(String) param.get(
"DescriptionPath"),
debug);
System.out.println(); 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);
if (entries == null) { String sDescriptionPath = (String) param.get("DescriptionPath");
System.out.println("Couldn't get Description for Job: " + job); DescEntry[] entries = dg.getDescriptionFor(job, sDescriptionPath, debug);
return false; // System.out.println();
}
if (entries == null)
{
System.out.println("Couldn't get Description for Job: " + job);
return false;
}
// String officeProviderName = (String) param.get("OfficeProvider"); // String officeProviderName = (String) param.get("OfficeProvider");
// AppProvider office = (AppProvider) dcl.getInstance(officeProviderName); // AppProvider office = (AppProvider) dcl.getInstance(officeProviderName);
@@ -110,265 +118,276 @@ public class java_fat implements TestBase {
// System.exit(-1); // System.exit(-1);
// } // }
AppProvider office = startOffice(param); m_aOffice = startOffice(param);
boolean firstRun = true; boolean firstRun = true;
for (int l = 0; l < entries.length; l++) { for (int l = 0; l < entries.length; l++)
if (entries[l] == null) { {
continue; if (entries[l] == null)
} {
continue;
if (entries[l].hasErrorMsg) {
System.out.println(entries[l].ErrorMsg);
continue;
}
if (!firstRun && newOffice) {
if (!office.closeExistingOffice(param, true)) {
office.disposeManager(param);
} }
startOffice(param);
} if (entries[l].hasErrorMsg)
firstRun = false; {
System.out.println(entries[l].ErrorMsg);
retValue = false;
continue;
}
if (!firstRun && newOffice)
{
if (!m_aOffice.closeExistingOffice(param, true))
{
m_aOffice.disposeManager(param);
}
startOffice(param);
}
firstRun = false;
// XMultiServiceFactory msf = (XMultiServiceFactory) office.getManager( // XMultiServiceFactory msf = (XMultiServiceFactory) office.getManager(
// param); // param);
XMultiServiceFactory msf = (XMultiServiceFactory) param.getMSF(); XMultiServiceFactory msf = (XMultiServiceFactory) param.getMSF();
if (msf == null) { if (msf == null)
retValue = false; {
retValue = false;
continue; continue;
} }
// param.put("ServiceFactory", msf); // param.put("ServiceFactory", msf);
DescEntry entry = entries[l]; DescEntry entry = entries[l];
//get some helper classes //get some helper classes
Summarizer sumIt = new Summarizer(); Summarizer sumIt = new Summarizer();
TestCase tCase = null; TestCase tCase = null;
try { try
tCase = (TestCase) dcl.getInstance("mod._" + {
entry.entryName); tCase = (TestCase) dcl.getInstance("mod._" + entry.entryName);
} catch (java.lang.IllegalArgumentException ie) { }
entry.ErrorMsg = ie.getMessage(); catch (java.lang.IllegalArgumentException ie)
entry.hasErrorMsg = true; {
} catch (java.lang.NoClassDefFoundError ie) { entry.ErrorMsg = ie.getMessage();
entry.ErrorMsg = ie.getMessage(); entry.hasErrorMsg = true;
entry.hasErrorMsg = true; }
} catch (java.lang.NoClassDefFoundError ie)
{
entry.ErrorMsg = ie.getMessage();
entry.hasErrorMsg = true;
}
if (tCase == null) { if (tCase == null)
Summarizer.summarizeDown(entry, entry.ErrorMsg); {
Summarizer.summarizeDown(entry, entry.ErrorMsg);
LogWriter sumObj = OutProducerFactory.createOutProducer(param); LogWriter sumObj = OutProducerFactory.createOutProducer(param);
entry.UserDefinedParams = param; entry.UserDefinedParams = param;
sumObj.initialize(entry, logging); sumObj.initialize(entry, logging);
sumObj.summary(entry); sumObj.summary(entry);
continue;
}
if (debug) {
System.out.println("sleeping 5 seconds..");
}
util.utils.shortWait(5000);
System.out.println("Creating: " + entry.entryName);
LogWriter log = (LogWriter) dcl.getInstance(
(String) param.get("LogWriter"));
log.initialize(entry, logging);
entry.UserDefinedParams = param;
TestEnvironment tEnv = null;
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());
LogWriter sumObj = OutProducerFactory.createOutProducer(param);
entry.UserDefinedParams = param;
sumObj.initialize(entry, logging);
sumObj.summary(entry);
continue;
}
System.out.println(tCase.getObjectName() + " recreated ");
for (int j = 0; j < entry.SubEntryCount; j++) {
if (!entry.SubEntries[j].isToTest) {
Summarizer.summarizeDown(entry.SubEntries[j],
"not part of the job");
continue; continue;
} }
if ((exclusions != null) && (exclusions.contains(entry.SubEntries[j].longName))) { if (debug)
Summarizer.summarizeDown(entry.SubEntries[j], {
"known issue"); System.out.println("sleeping 5 seconds..");
}
util.utils.shortWait(5000);
System.out.println("Creating: " + entry.entryName);
LogWriter log = (LogWriter) dcl.getInstance((String) param.get("LogWriter"));
log.initialize(entry, logging);
entry.UserDefinedParams = param;
TestEnvironment tEnv = null;
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());
LogWriter sumObj = OutProducerFactory.createOutProducer(param);
entry.UserDefinedParams = param;
sumObj.initialize(entry, logging);
sumObj.summary(entry);
continue; continue;
} }
System.out.println("running: '" + entry.SubEntries[j].entryName + "'"); System.out.println(tCase.getObjectName() + " recreated ");
LogWriter ifclog = (LogWriter) dcl.getInstance( for (int j = 0; j < entry.SubEntryCount; j++)
(String) param.get("LogWriter")); {
DescEntry aSubEntry = entry.SubEntries[j];
if (!aSubEntry.isToTest)
{
Summarizer.summarizeDown(aSubEntry, "not part of the job");
ifclog.initialize(entry.SubEntries[j], logging); continue;
entry.SubEntries[j].UserDefinedParams = param;
entry.SubEntries[j].Logger = ifclog;
if ((tEnv == null) || tEnv.isDisposed()) {
helper.ProcessHandler ph = (helper.ProcessHandler) param.get(
"AppProvider");
if (ph != null) {
office.closeExistingOffice(param, true);
shortWait(5000);
} }
tEnv = getEnv(entry, param); if ((exclusions != null) && (exclusions.contains(aSubEntry.longName)))
} {
Summarizer.summarizeDown(aSubEntry, "known issue");
MultiMethodTest ifc = null; continue;
lib.TestResult res = null; }
// run the interface test twice if it failed. System.out.println("running: '" + aSubEntry.entryName + "'");
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) { LogWriter ifclog = (LogWriter) dcl.getInstance( (String) param.get("LogWriter"));
office.closeExistingOffice(param, true);
shortWait(5000);
}
ifclog.initialize(aSubEntry, logging);
aSubEntry.UserDefinedParams = param;
aSubEntry.Logger = ifclog;
if ((tEnv == null) || tEnv.isDisposed())
{
closeExistingOffice();
tEnv = getEnv(entry, param); tEnv = getEnv(entry, param);
if (countInterfaceTestRun < 2) { }
finished = false;
} else { MultiMethodTest ifc = null;
Summarizer.summarizeDown(entry.SubEntries[j], lib.TestResult res = null;
e.toString() + ".FAILED");
// 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)
if (res != null) { {
for (int k = 0; k < entry.SubEntries[j].SubEntryCount; k++) { for (int k = 0; k < aSubEntry.SubEntryCount; k++)
if (res.hasMethod( {
entry.SubEntries[j].SubEntries[k].entryName)) { DescEntry aSubSubEntry = aSubEntry.SubEntries[k];
entry.SubEntries[j].SubEntries[k].State = res.getStatusFor( if (res.hasMethod( aSubSubEntry.entryName))
entry.SubEntries[j].SubEntries[k].entryName).toString(); {
aSubSubEntry.State = res.getStatusFor(aSubSubEntry.entryName).toString();
}
} }
} }
sumIt.summarizeUp(aSubEntry);
LogWriter sumIfc = OutProducerFactory.createOutProducer(param);
aSubEntry.UserDefinedParams = param;
sumIfc.initialize(aSubEntry, logging);
sumIfc.summary(aSubEntry);
}
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");
}
sumIt.summarizeUp(entry);
LogWriter sumObj = OutProducerFactory.createOutProducer(param);
sumObj.initialize(entry, logging);
sumObj.summary(entry);
}
if (entries.length > 0)
{
System.out.println();
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++;
}
} }
sumIt.summarizeUp(entry.SubEntries[j]); System.out.println(counter + " of " + entries.length + " tests failed");
LogWriter sumIfc = OutProducerFactory.createOutProducer(param);
entry.SubEntries[j].UserDefinedParams = param;
sumIfc.initialize(entry.SubEntries[j], logging);
sumIfc.summary(entry.SubEntries[j]);
} }
try { closeExistingOffice();
if (!keepdocument) { return retValue;
tCase.cleanupTestCase(param);
}
} catch (Exception e) {
System.out.println("couldn't cleanup");
} catch (java.lang.NoClassDefFoundError e) {
System.out.println("couldn't cleanup");
}
sumIt.summarizeUp(entry);
LogWriter sumObj = OutProducerFactory.createOutProducer(param);
sumObj.initialize(entry, logging);
sumObj.summary(entry);
} }
if (entries.length > 1) { private TestEnvironment getEnv(DescEntry entry, TestParameters param)
System.out.println(); {
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++;
}
}
System.out.println(counter + " of " + entries.length +
" tests failed");
}
helper.ProcessHandler ph = (helper.ProcessHandler) param.get(
"AppProvider");
if (ph != null) {
office.closeExistingOffice(param, true);
shortWait(5000);
}
return retValue;
}
protected TestEnvironment getEnv(DescEntry entry, TestParameters param) {
// if (dcl == null) // if (dcl == null)
// dcl = new DynamicClassLoader(); // dcl = new DynamicClassLoader();
// String officeProviderName = (String) param.get("OfficeProvider"); // String officeProviderName = (String) param.get("OfficeProvider");
@@ -389,143 +408,172 @@ public class java_fat implements TestBase {
// //
// param.put("ServiceFactory", msf); // param.put("ServiceFactory", msf);
AppProvider office = startOffice(param); // AppProvider office = startOffice(param);
TestCase tCase = null; TestCase tCase = null;
try { try
tCase = (TestCase) dcl.getInstance("mod._" + entry.entryName); {
} catch (java.lang.IllegalArgumentException ie) { tCase = (TestCase) dcl.getInstance("mod._" + entry.entryName);
entry.ErrorMsg = ie.getMessage(); }
entry.hasErrorMsg = true; catch (java.lang.IllegalArgumentException ie)
} catch (java.lang.NoClassDefFoundError ie) { {
entry.ErrorMsg = ie.getMessage(); entry.ErrorMsg = ie.getMessage();
entry.hasErrorMsg = true; entry.hasErrorMsg = true;
}
catch (java.lang.NoClassDefFoundError ie)
{
entry.ErrorMsg = ie.getMessage();
entry.hasErrorMsg = true;
}
System.out.println("Creating: " + entry.entryName);
entry.UserDefinedParams = param;
LogWriter log = (LogWriter) dcl.getInstance((String) param.get("LogWriter"));
log.initialize(entry, logging);
tCase.setLogWriter((PrintWriter) log);
TestEnvironment tEnv = null;
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());
closeExistingOffice();
entry.ErrorMsg = e.getMessage();
entry.hasErrorMsg = true;
}
return tEnv;
} }
System.out.println("Creating: " + entry.entryName); private void closeExistingOffice()
{
helper.ProcessHandler ph = (helper.ProcessHandler) m_aParams.get("AppProvider");
entry.UserDefinedParams = param; if (ph != null)
{
LogWriter log = (LogWriter) dcl.getInstance( m_aOffice.closeExistingOffice(m_aParams, true);
(String) param.get("LogWriter"));
log.initialize(entry, logging);
tCase.setLogWriter((PrintWriter) log);
TestEnvironment tEnv = null;
try {
tCase.initializeTestCase(param);
tEnv = tCase.getTestEnvironment(param);
} catch (com.sun.star.lang.DisposedException de) {
System.out.println("Office disposed");
helper.ProcessHandler ph = (helper.ProcessHandler) param.get(
"AppProvider");
if (ph != null) {
office.closeExistingOffice(param, true);
shortWait(5000);
}
} catch (lib.StatusException e) {
System.out.println(e.getMessage());
helper.ProcessHandler ph = (helper.ProcessHandler) param.get(
"AppProvider");
if (ph != null) {
office.closeExistingOffice(param, true);
shortWait(5000); shortWait(5000);
} }
entry.ErrorMsg = e.getMessage();
entry.hasErrorMsg = true;
} }
return tEnv; private void shortWait(int millis)
} {
try
protected void shortWait(int millis) { {
try { Thread.sleep(millis);
Thread.sleep(millis); }
} catch (java.lang.InterruptedException ie) { 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);
} }
return entryList;
} }
while (line != null) { private Vector getExclusionList(String url, boolean debug)
try { {
if (!line.startsWith("#") && (line.length() > 1)) { Vector entryList = new Vector();
entryList.add(line.trim()); String line = "#";
} BufferedReader exclusion = null;
line = exclusion.readLine(); try
} catch (java.io.IOException ioe) { {
if (debug) { exclusion = new BufferedReader(new FileReader(url));
System.out.println( }
"Exception while reading exclusion list"); catch (java.io.FileNotFoundException fnfe)
{
if (debug)
{
System.out.println("Couldn't find file " + url);
} }
return entryList; return entryList;
} }
}
try { while (line != null)
exclusion.close(); {
} catch (java.io.IOException ioe) { try
if (debug) { {
System.out.println("Couldn't close file " + url); 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");
}
return entryList;
}
}
try
{
exclusion.close();
}
catch (java.io.IOException ioe)
{
if (debug)
{
System.out.println("Couldn't close file " + url);
}
return entryList;
} }
return entryList; return entryList;
} }
return entryList;
}
private TestResult executeInterfaceTest( private TestResult executeInterfaceTest(
DescEntry entry, TestEnvironment tEnv, TestParameters param) DescEntry entry, TestEnvironment tEnv, TestParameters param)
throws IllegalArgumentException, java.lang.NoClassDefFoundError { throws IllegalArgumentException, java.lang.NoClassDefFoundError
MultiMethodTest ifc = (MultiMethodTest) dcl.getInstance(entry.entryName); {
return ifc.run(entry, tEnv, param); MultiMethodTest ifc = (MultiMethodTest) dcl.getInstance(entry.entryName);
} return ifc.run(entry, tEnv, param);
private AppProvider startOffice(lib.TestParameters param) {
if (dcl == null) {
dcl = new DynamicClassLoader();
} }
String officeProviderName = (String) param.get("OfficeProvider"); private AppProvider startOffice(lib.TestParameters param)
AppProvider office = (AppProvider) dcl.getInstance(officeProviderName); {
if (office == null) { if (dcl == null)
System.out.println("ERROR: Wrong parameter 'OfficeProvider', " + {
" it cannot be instantiated."); dcl = new DynamicClassLoader();
System.exit(-1); }
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);
}
XMultiServiceFactory msf = (XMultiServiceFactory) office.getManager(param);
if (msf != null)
{
param.put("ServiceFactory", msf);
}
return office;
} }
XMultiServiceFactory msf = (XMultiServiceFactory) office.getManager(
param);
if (msf != null){
param.put("ServiceFactory", msf);
}
return office;
}
} }

View File

@@ -280,4 +280,4 @@ public abstract class ComplexTestCase extends Assurance implements ComplexTest
{ {
return this.getClass().getName(); return this.getClass().getName();
} }
} }

View File

@@ -7,7 +7,8 @@ import java.lang.reflect.Method;
* Invoke a method of a class in an own thread. Provide a method to end * Invoke a method of a class in an own thread. Provide a method to end
* the thread. * the thread.
*/ */
public class MethodThread extends Thread { public class MethodThread extends Thread
{
/** The method that should be executed **/ /** The method that should be executed **/
private Method mTestMethod = null; private Method mTestMethod = null;
@@ -19,7 +20,6 @@ public class MethodThread extends Thread {
private String mErrMessage = null; private String mErrMessage = null;
/** Did an Exception happen? **/ /** Did an Exception happen? **/
private boolean mExceptionHappened = false; private boolean mExceptionHappened = false;
private Object[] mParameter = null; private Object[] mParameter = null;
/** /**
@@ -28,13 +28,15 @@ public class MethodThread extends Thread {
* @param invokeClass The class where the method is invoked. * @param invokeClass The class where the method is invoked.
* @param log The logging mechanism. * @param log The logging mechanism.
*/ */
public MethodThread(Method testMethod, Object invokeClass, PrintWriter log) { public MethodThread(Method testMethod, Object invokeClass, PrintWriter log)
{
mTestMethod = testMethod; mTestMethod = testMethod;
mInvokeClass = invokeClass; mInvokeClass = invokeClass;
mLog = log; mLog = log;
} }
public MethodThread(Method testMethod, Object invokeClass, Object[] parameter, PrintWriter log) { public MethodThread(Method testMethod, Object invokeClass, Object[] parameter, PrintWriter log)
{
mTestMethod = testMethod; mTestMethod = testMethod;
mInvokeClass = invokeClass; mInvokeClass = invokeClass;
mParameter = parameter; mParameter = parameter;
@@ -44,22 +46,29 @@ public class MethodThread extends Thread {
/** /**
* Invoke the method. * Invoke the method.
*/ */
public void run() { public void run()
try { {
try
{
mTestMethod.invoke(mInvokeClass, mParameter); mTestMethod.invoke(mInvokeClass, mParameter);
} }
catch(IllegalAccessException e) { catch (IllegalAccessException e)
{
e.printStackTrace(mLog); e.printStackTrace(mLog);
mErrMessage = e.getMessage(); mErrMessage = e.getMessage();
mExceptionHappened = true; mExceptionHappened = true;
} }
catch(java.lang.reflect.InvocationTargetException e) { catch (java.lang.reflect.InvocationTargetException e)
{
Throwable t = e.getTargetException(); Throwable t = e.getTargetException();
if (!(t instanceof ComplexTestCase.AssureException)) { if (!(t instanceof ComplexTestCase.AssureException))
{
t.printStackTrace(mLog); t.printStackTrace(mLog);
mErrMessage = t.getMessage(); mErrMessage = t.getMessage();
if (mErrMessage == null) if (mErrMessage == null)
{
mErrMessage = t.toString(); mErrMessage = t.toString();
}
mExceptionHappened = true; mExceptionHappened = true;
} }
@@ -70,7 +79,8 @@ public class MethodThread extends Thread {
* Get the error message * Get the error message
* @return The error message. * @return The error message.
*/ */
public String getErrorMessage() { public String getErrorMessage()
{
return mErrMessage; return mErrMessage;
} }
@@ -78,18 +88,22 @@ public class MethodThread extends Thread {
* Is there an error message? * Is there an error message?
* @return True, if an error did happen. * @return True, if an error did happen.
*/ */
public boolean hasErrorMessage() { public boolean hasErrorMessage()
{
return mExceptionHappened; return mExceptionHappened;
} }
/** /**
* Stop the running method. * Stop the running method.
*/ */
public void destroy() { public void destroy()
try { {
try
{
interrupt(); interrupt();
} }
catch(SecurityException e) { catch (SecurityException e)
{
e.printStackTrace(mLog); e.printStackTrace(mLog);
mErrMessage = e.getMessage(); mErrMessage = e.getMessage();
mExceptionHappened = true; mExceptionHappened = true;

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,5 @@
/* /*
************************************************************************* *************************************************************************
* *
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
@@ -43,7 +43,8 @@ import util.utils;
* Implementaion of the interface CwsDataExchange * Implementaion of the interface CwsDataExchange
* @see share.CwsDataExchange * @see share.CwsDataExchange
*/ */
public class CwsDataExchangeImpl implements CwsDataExchange { public class CwsDataExchangeImpl implements CwsDataExchange
{
private final String cwsName; private final String cwsName;
private final TestParameters param; private final TestParameters param;
@@ -51,7 +52,8 @@ public class CwsDataExchangeImpl implements CwsDataExchange {
private final BuildEnvTools bet; private final BuildEnvTools bet;
private final boolean mDebug; private final boolean mDebug;
public CwsDataExchangeImpl(String cwsName, TestParameters param, LogWriter log) throws ParameterNotFoundException { public CwsDataExchangeImpl(String cwsName, TestParameters param, LogWriter log) throws ParameterNotFoundException
{
this.cwsName = cwsName; this.cwsName = cwsName;
this.param = param; this.param = param;
this.log = log; this.log = log;
@@ -59,15 +61,22 @@ public class CwsDataExchangeImpl implements CwsDataExchange {
mDebug = param.getBool(PropertyName.DEBUG_IS_ACTIVE); mDebug = param.getBool(PropertyName.DEBUG_IS_ACTIVE);
} }
public ArrayList getModules() { public ArrayList getModules()
{
// the cwstouched command send its version information to StdErr. // the cwstouched command send its version information to StdErr.
// A piping from StdErr to SdtOut the tcsh does not support. // A piping from StdErr to SdtOut the tcsh does not support.
// To find the output easily the echo command is used // To find the output easily the echo command is used
final String[] commands = {"echo cwstouched starts here", "cwstouched", "echo cwstouched ends here"}; final String[] commands =
{
"echo cwstouched starts here",
"cwstouched",
"echo cwstouched ends here"
};
final ProcessHandler procHdl = bet.runCommandsInEnvironmentShell(commands, null, 20000); final ProcessHandler procHdl = bet.runCommandsInEnvironmentShell(commands, null, 20000);
if (mDebug) { if (mDebug)
{
log.println("---> Output of getModules:"); log.println("---> Output of getModules:");
log.println(procHdl.getOutputText()); log.println(procHdl.getOutputText());
log.println("<--- Output of getModules"); log.println("<--- Output of getModules");
@@ -79,33 +88,44 @@ public class CwsDataExchangeImpl implements CwsDataExchange {
final String[] outs = procHdl.getOutputText().split("\n"); final String[] outs = procHdl.getOutputText().split("\n");
final ArrayList<String> moduleNames = new ArrayList<String>(); final ArrayList<String> moduleNames = new ArrayList<String>();
boolean start = false; boolean bStart = false;
for (int i = 0; i < outs.length; i++) { for (int i = 0; i < outs.length; i++)
{
final String line = outs[i]; final String line = outs[i];
if (line.startsWith("cwstouched ends here")) { if (line.startsWith("cwstouched starts here"))
start = false; {
bStart = true;
continue;
} }
if (start && line.length() > 1) { if (line.startsWith("cwstouched ends here"))
{
bStart = false;
continue;
}
if (bStart && line.length() > 1)
{
moduleNames.add(line); moduleNames.add(line);
} }
if (line.startsWith("cwstouched starts here")) {
start = true;
}
} }
return moduleNames; return moduleNames;
} }
public void setUnoApiCwsStatus(boolean status) { public void setUnoApiCwsStatus(boolean status)
{
FileWriter out = null; FileWriter out = null;
String statusFile = null; String statusFile = null;
try { try
{
final String stat = status ? ".PASSED.OK" : ".PASSED.FAILED"; final String stat = status ? ".PASSED.OK" : ".PASSED.FAILED";
statusFile = utils.getUsersTempDir() + System.getProperty("file.separator") + "UnoApiCwsStatus." + statusFile = utils.getUsersTempDir() +
(String) param.get(PropertyName.VERSION) + "_" + param.get(PropertyName.OPERATING_SYSTEM) + stat + ".txt"; System.getProperty("file.separator") +
"UnoApiCwsStatus." +
(String) param.get(PropertyName.VERSION) +
"_" + param.get(PropertyName.OPERATING_SYSTEM) + stat + ".txt";
out = new FileWriter(statusFile); out = new FileWriter(statusFile);
@@ -113,16 +133,26 @@ public class CwsDataExchangeImpl implements CwsDataExchange {
out.flush(); out.flush();
out.close(); out.close();
final String[] commands = {"cwsattach " + statusFile}; final String[] commands =
{
"cwsattach " + statusFile
};
bet.runCommandsInEnvironmentShell(commands, null, 5000); 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()); System.out.println("ERROR: could not attach file '" + statusFile + "' to cws\n" + ex.toString());
} finally { }
try { finally
{
try
{
out.close(); out.close();
} catch (IOException ex) { }
catch (IOException ex)
{
ex.printStackTrace(); ex.printStackTrace();
} }
} }

View File

@@ -366,17 +366,20 @@ public class ProcessHandler
{ {
ow = (OfficeWatcher) param.get(PropertyName.OFFICE_WATCHER); ow = (OfficeWatcher) param.get(PropertyName.OFFICE_WATCHER);
} }
if (ow != null)
{
ow.ping();
}
int hangcheck = 10;
while (!this.isFinished() && changedText) while (!this.isFinished() && changedText)
{ {
count++; count++;
if (ow != null) // dbg("runCommand: waiting " + mTimeOut / 1000 + " seconds while command execution is ongoing... " + count);
{ // shortWait(mTimeOut);
ow.ping(); // shortWait(2000); // wait 2 seconds.
}
dbg("runCommand: waiting " + mTimeOut / 1000 + " seconds while command execution is ongoing... " + count);
shortWait(mTimeOut);
//waitFor(mTimeOut); //waitFor(mTimeOut);
waitFor(2000, false); // wait but don't kill
if (ow != null) 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 // check for changes in the output stream. If there are no changes, the process maybe hangs
if (!this.isFinished()) if (!this.isFinished())
{ {
if (this.getOutputText().length() == memText.length()) hangcheck--;
if (hangcheck < 0)
{ {
changedText = false; String sOutputText = getOutputText();
dbg("runCommand Could not detect changes in output stream!!!"); 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 > "); stderr = new Pump(m_aProcess.getErrorStream(), log, "err > ");
stdIn = new PrintStream(m_aProcess.getOutputStream()); stdIn = new PrintStream(m_aProcess.getOutputStream());
// int nExitValue = m_aProcess.exitValue();
// int dummy = 0;
dbg("execute: flush io-streams"); dbg("execute: flush io-streams");
flushInput(); flushInput();
@@ -578,7 +583,12 @@ public class ProcessHandler
* @return <code>true</code> if process correctly exited * @return <code>true</code> if process correctly exited
* (exit code doesn't affect to this result). * (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()) if (isFinished())
{ {
@@ -638,11 +648,14 @@ public class ProcessHandler
} }
} }
if (!isFinished) if (bKillProcessAfterTimeout == true)
{ {
log.println("Going to destroy the process!!"); if (!isFinished)
m_aProcess.destroy(); {
log.println("Process has been destroyed!"); log.println("Going to destroy the process!!");
m_aProcess.destroy();
log.println("Process has been destroyed!");
}
} }
// Removed as hung up in SDK test 'PathSettings' // Removed as hung up in SDK test 'PathSettings'
// try { // try {

View File

@@ -27,7 +27,6 @@
* for a copy of the LGPLv3 License. * for a copy of the LGPLv3 License.
* *
************************************************************************/ ************************************************************************/
package lib; package lib;
import java.io.PrintWriter; import java.io.PrintWriter;
@@ -43,7 +42,6 @@ import share.DescEntry;
import lib.TestParameters; import lib.TestParameters;
import stats.Summarizer; import stats.Summarizer;
/** /**
* The class supports method based interface tests development. * The class supports method based interface tests development.
* *
@@ -81,38 +79,34 @@ import stats.Summarizer;
* *
* @see TestResult * @see TestResult
*/ */
public class MultiMethodTest { public class MultiMethodTest
{
/** /**
* Contains the TestEnvironment being tested, to allow for tests to access * Contains the TestEnvironment being tested, to allow for tests to access
* it. * it.
*/ */
protected TestEnvironment tEnv; protected TestEnvironment tEnv;
/** /**
* Contains the TestParameters for the tests, to allow for tests to access * Contains the TestParameters for the tests, to allow for tests to access
* it. * it.
*/ */
protected TestParameters tParam; protected TestParameters tParam;
/** /**
* Contains the Description for the test * Contains the Description for the test
* it. * it.
*/ */
protected DescEntry entry; protected DescEntry entry;
/** /**
* Contains a writer to log an information about the interface testing, to * Contains a writer to log an information about the interface testing, to
* allows for tests to access it. * allows for tests to access it.
*/ */
protected PrintWriter log; protected PrintWriter log;
/** /**
* Contains the TestResult instance for the interface test to collect * Contains the TestResult instance for the interface test to collect
* information about methods test. * information about methods test.
*/ */
protected TestResult tRes; protected TestResult tRes;
/** /**
* Contains names of the methods have been alreadycalled * Contains names of the methods have been alreadycalled
*/ */
@@ -123,7 +117,8 @@ public class MultiMethodTest {
* *
* @param tEnv the environment to dispose * @param tEnv the environment to dispose
*/ */
public void disposeEnvironment( TestEnvironment tEnv ) { public void disposeEnvironment(TestEnvironment tEnv)
{
disposeEnvironment(); disposeEnvironment();
} }
@@ -132,10 +127,11 @@ public class MultiMethodTest {
* *
* @see #disposeEnvironment(TestEnvironment) * @see #disposeEnvironment(TestEnvironment)
*/ */
public void disposeEnvironment() { public void disposeEnvironment()
{
tEnv.dispose(); tEnv.dispose();
TestCase tCase = tEnv.getTestCase(); 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 * called. After them, after() method is called, to allow cleaning up the
* stuff initialized in before() and test methods. * stuff initialized in before() and test methods.
* *
* @param entry the interface test state
* @param tEnv the environment to test * @param tEnv the environment to test
* @param ifcState the interface test state
* @param tParam the parameters of the test * @param tParam the parameters of the test
* *
* @see #before * @see #before
* @see #after * @see #after
*/ */
public TestResult run( DescEntry entry, TestEnvironment tEnv, TestParameters tParam ) { public TestResult run(DescEntry entry, TestEnvironment tEnv, TestParameters tParam)
{
log = (PrintWriter) entry.Logger; log = (PrintWriter) entry.Logger;
this.tEnv = tEnv; this.tEnv = tEnv;
this.tParam = tParam; this.tParam = tParam;
this.log = log; // this.log = log;
this.entry = entry; this.entry = entry;
this.tRes = new TestResult(); this.tRes = new TestResult();
Class testedClass; Class testedClass;
String ifcName = getInterfaceName(); // Some fake code for a self test.
System.out.println("checking : "+ifcName); // 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 // defining a name of the class corresponding to the tested interface
// or service // or service
String testedClassName; String testedClassName;
testedClassName = getTestedClassName(); testedClassName = getTestedClassName();
if (entry.EntryType.equals("service")) { if (entry.EntryType.equals("service"))
testedClassName = "com.sun.star.beans.XPropertySet"; {
} testedClassName = "com.sun.star.beans.XPropertySet";
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; 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;
}
//setting the field oObj
setField("oObj", oObj);
} }
//setting the field oObj
setField("oObj",oObj);
// to perform some stuff before all method tests // to perform some stuff before all method tests
try { try
{
before(); before();
} catch (Exception e){ }
catch (Exception e)
{
setSubStates(e.toString()); setSubStates(e.toString());
return tRes; return tRes;
} }
// executing methods tests // executing methods tests
for (int i=0;i<entry.SubEntryCount;i++) { for (int i = 0; i < entry.SubEntryCount; i++)
try { {
executeMethod( entry.SubEntries[i].entryName ); DescEntry aSubEntry = entry.SubEntries[i];
} catch (Exception e){ try
log.println("Exception while checking: "+ {
entry.SubEntries[i].entryName+" : "+e.getMessage()); executeMethod(aSubEntry.entryName);
}
catch (Exception e)
{
log.println("Exception while checking: " + aSubEntry.entryName + " : " + e.getMessage());
} }
} }
// to perform some stuff after all method tests // to perform some stuff after all method tests
try { try
{
after(); after();
} catch (Exception e){} }
catch (Exception e)
{
}
return tRes; return tRes;
} }
@@ -241,21 +258,23 @@ public class MultiMethodTest {
* Is called before calling method tests, but after initialization. * Is called before calling method tests, but after initialization.
* Subclasses may override to perform actions before method tests. * Subclasses may override to perform actions before method tests.
*/ */
protected void before() { protected void before()
{
} }
/** /**
* Is called after calling method tests. Subclasses may override * Is called after calling method tests. Subclasses may override
* to perform actions after method tests. * to perform actions after method tests.
*/ */
protected void after() { protected void after()
{
} }
/** /**
* @return the name of the interface or the service tested. * @return the name of the interface or the service tested.
*/ */
protected String getTestedClassName() { protected String getTestedClassName()
{
String clsName = this.getClass().getName(); String clsName = this.getClass().getName();
int firstDot = clsName.indexOf("."); int firstDot = clsName.indexOf(".");
@@ -263,13 +282,12 @@ public class MultiMethodTest {
String append = "com.sun.star."; String append = "com.sun.star.";
if (entry.longName.indexOf("::drafts::com::")>-1) { if (entry.longName.indexOf("::drafts::com::") > -1)
{
append = "drafts.com.sun.star."; append = "drafts.com.sun.star.";
} }
return append return append + clsName.substring(firstDot + 1, lastDot + 1) + clsName.substring(lastDot + 2);
+ 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 methName the method name to set status
* @param methStatus the status to set to the method * @param methStatus the status to set to the method
*/ */
protected void setStatus( String methName, Status methStatus ) { protected void setStatus(String methName, Status methStatus)
tRes.tested( methName, methStatus ); {
tRes.tested(methName, methStatus);
} }
/** /**
* sets the substates * sets the substates
*/ */
protected void setSubStates(String msg) { protected void setSubStates(String msg)
for (int k=0;k<entry.SubEntryCount;k++) { {
entry.SubEntries[k].hasErrorMsg=true; for (int k = 0; k < entry.SubEntryCount; k++)
entry.SubEntries[k].ErrorMsg=msg; {
if (entry.SubEntries[k].State.equals("UNKNOWN")) { entry.SubEntries[k].hasErrorMsg = true;
entry.SubEntries[k].ErrorMsg = msg;
if (entry.SubEntries[k].State.equals("UNKNOWN"))
{
entry.SubEntries[k].State = msg; entry.SubEntries[k].State = msg;
} }
} }
@@ -299,9 +321,12 @@ public class MultiMethodTest {
/** /**
* Checks if the <code>method</code> is optional in the service. * Checks if the <code>method</code> is optional in the service.
*/ */
protected boolean isOptional(String method) { protected boolean isOptional(String method)
for (int k=0;k<entry.SubEntryCount;k++) { {
if (entry.SubEntries[k].entryName.equals(method)) { for (int k = 0; k < entry.SubEntryCount; k++)
{
if (entry.SubEntries[k].entryName.equals(method))
{
return entry.SubEntries[k].isOptional; return entry.SubEntries[k].isOptional;
} }
} }
@@ -311,8 +336,9 @@ public class MultiMethodTest {
/** /**
* Checks if the <code>method</code> test has been already called. * Checks if the <code>method</code> test has been already called.
*/ */
protected boolean isCalled( String method ) { protected boolean isCalled(String method)
return methCalled.contains( 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. * be called. The method checks this and if it is not called, calls it.
* If the method is failed or skipped, it throws StatusException. * 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); log.println("starting required method: " + method);
executeMethod( method ); executeMethod(method);
Status mtStatus = tRes.getStatusFor( method ); Status mtStatus = tRes.getStatusFor(method);
if ( mtStatus != null if (mtStatus != null && (!mtStatus.isPassed() || mtStatus.isFailed()))
&& (!mtStatus.isPassed() || mtStatus.isFailed()) ) { {
log.println( "! Required method " + method + " failed" ); log.println("! Required method " + method + " failed");
throw new StatusException( mtStatus ); throw new StatusException(mtStatus);
} }
} }
@@ -336,10 +363,12 @@ public class MultiMethodTest {
* Checks if the <code>method</code> was called, and if not, call it. * Checks if the <code>method</code> was called, and if not, call it.
* On contrary to requiredMethod(), he method doesn't check its status. * On contrary to requiredMethod(), he method doesn't check its status.
*/ */
protected void executeMethod( String method ) { protected void executeMethod(String method)
if ( ! isCalled( method ) ) { {
log.println("Execute: "+ method); if (!isCalled(method))
callMethod( method ); {
log.println("Execute: " + method);
callMethod(method);
log.println(method + ": " + tRes.getStatusFor(method)); log.println(method + ": " + tRes.getStatusFor(method));
} }
} }
@@ -347,7 +376,8 @@ public class MultiMethodTest {
/** /**
* Just calls the <code>method</code> test. * Just calls the <code>method</code> test.
*/ */
protected void callMethod(String method) { protected void callMethod(String method)
{
methCalled.add(method); methCalled.add(method);
invokeTestMethod(getMethodFor(method), method); invokeTestMethod(getMethodFor(method), method);
} }
@@ -359,31 +389,47 @@ public class MultiMethodTest {
* @param meth the subclass' method to invoke * @param meth the subclass' method to invoke
* @param methName the name of the method * @param methName the name of the method
*/ */
protected void invokeTestMethod(Method meth, String methName) { protected void invokeTestMethod(Method meth, String methName)
if (meth == null) { {
setStatus( methName, Status.skipped( false ) ); if (meth == null)
} else { {
setStatus(methName, Status.skipped(false));
}
else
{
Status stat; Status stat;
try { try
{
meth.invoke(this, new Object[0]); meth.invoke(this, new Object[0]);
return; return;
} catch (InvocationTargetException itE) { }
catch (InvocationTargetException itE)
{
Throwable t = itE.getTargetException(); Throwable t = itE.getTargetException();
if ( t instanceof StatusException ) { if (t instanceof StatusException)
stat = ((StatusException)t).getStatus(); {
} else { stat = ((StatusException) t).getStatus();
}
else
{
t.printStackTrace(log); t.printStackTrace(log);
stat = Status.exception(t); stat = Status.exception(t);
} }
} catch (IllegalAccessException iaE) { }
catch (IllegalAccessException iaE)
{
iaE.printStackTrace(log); iaE.printStackTrace(log);
stat = Status.exception(iaE); stat = Status.exception(iaE);
} catch (IllegalArgumentException iaE) { }
catch (IllegalArgumentException iaE)
{
iaE.printStackTrace(log); iaE.printStackTrace(log);
stat = Status.exception(iaE); stat = Status.exception(iaE);
} catch (ClassCastException ccE) { }
catch (ClassCastException ccE)
{
ccE.printStackTrace(log); ccE.printStackTrace(log);
stat = Status.exception(ccE); stat = Status.exception(ccE);
} }
@@ -397,18 +443,23 @@ public class MultiMethodTest {
* *
* @return the testing method, if found, <tt>null</tt> otherwise * @return the testing method, if found, <tt>null</tt> otherwise
*/ */
protected Method getMethodFor(String method) { protected Method getMethodFor(String method)
{
String mName = "_" + method; String mName = "_" + method;
if (mName.endsWith("()")) { if (mName.endsWith("()"))
{
mName = mName.substring(0, mName.length() - 2); mName = mName.substring(0, mName.length() - 2);
} }
final Class[] paramTypes = new Class[0]; final Class[] paramTypes = new Class[0];
try { try
{
return this.getClass().getDeclaredMethod(mName, paramTypes); return this.getClass().getDeclaredMethod(mName, paramTypes);
} catch (NoSuchMethodException nsmE) { }
catch (NoSuchMethodException nsmE)
{
return null; return null;
} }
} }
@@ -416,38 +467,43 @@ public class MultiMethodTest {
/** /**
* @return the name of the interface tested * @return the name of the interface tested
*/ */
public String getInterfaceName() { public String getInterfaceName()
{
String clName = this.getClass().getName(); String clName = this.getClass().getName();
return clName.substring( clName.lastIndexOf('.') + 1 ); return clName.substring(clName.lastIndexOf('.') + 1);
} }
/** /**
* Initializes <code>fieldName</code> of the subclass with * Initializes <code>fieldName</code> of the subclass with
* <code>value</code>. * <code>value</code>.
* *
* @return Status describing the result of the operation. * @return Status describing the result of the operation.
*/ */
protected Status setField( String fieldName, Object value) { protected Status setField(String fieldName, Object value)
{
Field objField; Field objField;
try { try
objField = this.getClass().getField( fieldName ); {
objField = this.getClass().getField(fieldName);
} }
catch( NoSuchFieldException nsfE ){ catch (NoSuchFieldException nsfE)
return Status.exception( nsfE ); {
return Status.exception(nsfE);
} }
try { try
objField.set( this, value ); {
objField.set(this, value);
return Status.passed(true); return Status.passed(true);
} }
catch( IllegalArgumentException iaE ){ catch (IllegalArgumentException iaE)
return Status.exception( iaE ); {
return Status.exception(iaE);
} }
catch( IllegalAccessException iaE ){ catch (IllegalAccessException iaE)
return Status.exception( iaE ); {
return Status.exception(iaE);
} }
} }
} }

View File

@@ -36,62 +36,76 @@ import java.util.StringTokenizer;
import java.util.Vector; import java.util.Vector;
/** /**
* *
* Base Interface to get a description for a given TestJob * Base Interface to get a description for a given TestJob
* *
*/ */
public abstract class DescGetter { public abstract class DescGetter
{
public abstract DescEntry[] getDescriptionFor(String entry, public abstract DescEntry[] getDescriptionFor(String entry,
String DescPath, String DescPath,
boolean debug); boolean debug);
protected abstract DescEntry getDescriptionForSingleJob(String job, protected abstract DescEntry getDescriptionForSingleJob(String job,
String descPath, String descPath,
boolean debug); boolean debug);
protected abstract String[] createScenario(String descPath, String job, protected abstract String[] createScenario(String descPath, String job,
boolean debug); boolean debug);
protected DescEntry[] getScenario(String url, String descPath, protected DescEntry[] getScenario(String url, String descPath,
boolean debug) { boolean debug)
{
Vector entryList = new Vector(); Vector entryList = new Vector();
String line = ""; String line = "";
BufferedReader scenario = null; BufferedReader scenario = null;
DescEntry[] entries = null; DescEntry[] entries = null;
try { try
{
scenario = new BufferedReader(new FileReader(url)); scenario = new BufferedReader(new FileReader(url));
} catch (java.io.FileNotFoundException fnfe) { }
catch (java.io.FileNotFoundException fnfe)
{
System.out.println("Couldn't find file " + url); System.out.println("Couldn't find file " + url);
return entries; return entries;
} }
while (line != null) { while (line != null)
try { {
if (line.startsWith("-o")) { try
{
if (line.startsWith("-o"))
{
String job = line.substring(3, line.length()).trim(); String job = line.substring(3, line.length()).trim();
DescEntry aEntry ; DescEntry aEntry;
// special in case several Interfaces are given comma separated // special in case several Interfaces are given comma separated
if (job.indexOf(",") < 0) { if (job.indexOf(",") < 0)
{
aEntry = getDescriptionForSingleJob(job, descPath, aEntry = getDescriptionForSingleJob(job, descPath,
debug); debug);
} else { }
else
{
ArrayList subs = getSubInterfaces(job); ArrayList subs = getSubInterfaces(job);
String partjob = job.substring(0, job.indexOf(",")).trim(); String partjob = job.substring(0, job.indexOf(",")).trim();
aEntry = getDescriptionForSingleJob(partjob, descPath, aEntry = getDescriptionForSingleJob(partjob, descPath,
debug); debug);
if (aEntry != null) { if (aEntry != null)
for (int i = 0; i < aEntry.SubEntryCount; i++) { {
for (int i = 0; i < aEntry.SubEntryCount; i++)
{
String subEntry = aEntry.SubEntries[i].longName; String subEntry = aEntry.SubEntries[i].longName;
int cpLength = aEntry.longName.length(); int cpLength = aEntry.longName.length();
subEntry = subEntry.substring(cpLength + 2, subEntry = subEntry.substring(cpLength + 2,
subEntry.length()); subEntry.length());
if (subs.contains(subEntry)) { if (subs.contains(subEntry))
{
aEntry.SubEntries[i].isToTest = true; aEntry.SubEntries[i].isToTest = true;
} }
} }
@@ -101,63 +115,82 @@ public abstract class DescGetter {
// line.substring(3).trim(), descPath, // line.substring(3).trim(), descPath,
// debug); // debug);
if (aEntry != null) if (aEntry != null)
{
entryList.add(aEntry); entryList.add(aEntry);
} else if (line.startsWith("-sce")) { }
}
else if (line.startsWith("-sce"))
{
DescEntry[] subs = getScenario(line.substring(5, DescEntry[] subs = getScenario(line.substring(5,
line.length()) line.length()).trim(), descPath,
.trim(), descPath, debug);
debug);
for (int i = 0; i < subs.length; i++) { for (int i = 0; i < subs.length; i++)
{
entryList.add(subs[i]); entryList.add(subs[i]);
} }
} else if (line.startsWith("-p")) { }
else if (line.startsWith("-p"))
{
String[] perModule = createScenario(descPath, String[] perModule = createScenario(descPath,
line.substring(3) line.substring(3).trim(), debug);
.trim(), debug);
for (int i = 0; i < perModule.length; i++) { for (int i = 0; i < perModule.length; i++)
{
DescEntry aEntry = getDescriptionForSingleJob( DescEntry aEntry = getDescriptionForSingleJob(
perModule[i].substring(3) perModule[i].substring(3).trim(),
.trim(), descPath, debug);
descPath, debug);
if (aEntry != null) if (aEntry != null)
{
entryList.add(aEntry); entryList.add(aEntry);
}
} }
} }
line = scenario.readLine(); line = scenario.readLine();
} catch (java.io.IOException ioe) { }
if (debug) { catch (java.io.IOException ioe)
{
if (debug)
{
System.out.println("Exception while reading scenario"); System.out.println("Exception while reading scenario");
} }
} }
} }
try { try
{
scenario.close(); scenario.close();
} catch (java.io.IOException ioe) { }
if (debug) { catch (java.io.IOException ioe)
{
if (debug)
{
System.out.println("Exception while closeing scenario"); System.out.println("Exception while closeing scenario");
} }
} }
if (entryList.size() == 0) if (entryList.size() == 0)
{
return null; return null;
}
entries = new DescEntry[entryList.size()]; entries = new DescEntry[entryList.size()];
entries = (DescEntry[]) entryList.toArray(entries); entries = (DescEntry[]) entryList.toArray(entries);
return entries; return entries;
} }
protected ArrayList getSubInterfaces(String job) { protected ArrayList getSubInterfaces(String job)
{
ArrayList namesList = new ArrayList(); ArrayList namesList = new ArrayList();
StringTokenizer st = new StringTokenizer(job, ","); StringTokenizer st = new StringTokenizer(job, ",");
for (int i = 0; st.hasMoreTokens(); i++) { for (int i = 0; st.hasMoreTokens(); i++)
{
String token = st.nextToken(); String token = st.nextToken();
if (token.indexOf(".") < 0) { if (token.indexOf(".") < 0)
{
namesList.add(token); namesList.add(token);
} }
} }

View File

@@ -429,7 +429,7 @@ public class DesktopTools {
* @param xModel the XModel of the document to bring to top * @param xModel the XModel of the document to bring to top
*/ */
public static void bringWindowToFront(XModel xModel){ 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 xTopWindow =
(XTopWindow) UnoRuntime.queryInterface( (XTopWindow) UnoRuntime.queryInterface(
@@ -440,7 +440,7 @@ public class DesktopTools {
} }
public static void bringWindowToFront(XComponent xComponent){ 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); XModel xModel = (XModel) UnoRuntime.queryInterface(XModel.class, xComponent);
if (xModel != null){ if (xModel != null){
bringWindowToFront(xModel); bringWindowToFront(xModel);

View File

@@ -44,7 +44,7 @@ import helper.BuildEnvTools;
import helper.ComplexDescGetter; import helper.ComplexDescGetter;
import helper.CwsDataExchangeImpl; import helper.CwsDataExchangeImpl;
import java.io.File; import java.io.File;
import java.io.FileFilter; // import java.io.FileFilter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
@@ -70,7 +70,8 @@ import util.utils;
* </ul> * </ul>
* *
*/ */
public class CheckModuleAPI extends ComplexTestCase { public class CheckModuleAPI extends ComplexTestCase
{
private static String mSRC_ROOT = null; private static String mSRC_ROOT = null;
private static boolean mIsInitialized = false; private static boolean mIsInitialized = false;
@@ -87,16 +88,21 @@ public class CheckModuleAPI extends ComplexTestCase {
* but this will take some time. * but this will take some time.
* Note: This funktionality is only reasonable with parameter <CODE>-noOffice true</CODE> * Note: This funktionality is only reasonable with parameter <CODE>-noOffice true</CODE>
*/ */
public void before() { public void before()
{
if (!mIsInitialized) { if (!mIsInitialized)
{
mIsInitialized = true; mIsInitialized = true;
try { try
{
bet = new BuildEnvTools(param, log); bet = new BuildEnvTools(param, log);
} catch (ParameterNotFoundException ex) { }
catch (ParameterNotFoundException ex)
{
this.failed(ex.toString(), false); this.failed(ex.toString(), false);
} }
@@ -111,11 +117,15 @@ public class CheckModuleAPI extends ComplexTestCase {
* let API tests run. * let API tests run.
* @param module * @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 testing module '" + module + "'");
log.println(utils.getDateTime() + "start new Office instance..."); log.println(utils.getDateTime() + "start new Office instance...");
// TODO: is Office started with this program?
final OfficeProvider officeProvider = new OfficeProvider(); final OfficeProvider officeProvider = new OfficeProvider();
log.println(utils.getDateTime() + "Receiving the ServiceManager of the Office "); log.println(utils.getDateTime() + "Receiving the ServiceManager of the Office ");
final XMultiServiceFactory msf = (XMultiServiceFactory) officeProvider.getManager(param); final XMultiServiceFactory msf = (XMultiServiceFactory) officeProvider.getManager(param);
assure("couldnot get ServiceFarcotry", msf != null, mContinue); assure("couldnot get ServiceFarcotry", msf != null, mContinue);
@@ -128,12 +138,12 @@ public class CheckModuleAPI extends ComplexTestCase {
final File fMakeFile = new File(sMakeFile); final File fMakeFile = new File(sMakeFile);
assure("ERROR: could not find makefile: '" + sMakeFile + "'", fMakeFile.exists(), mContinue); 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); final ProcessHandler procHdl = bet.runCommandsInEnvironmentShell(commands, fUnoapi, 0);
log.println("exit code of dmake: " + procHdl.getExitCode()); log.println("exit code of dmake: " + procHdl.getExitCode());
String test = procHdl.getOutputText(); String test = procHdl.getOutputText();
test = procHdl.getErrorText(); test += procHdl.getErrorText();
// if (mDebug) { // if (mDebug) {
// log.println("---> Output of dmake:"); // log.println("---> Output of dmake:");
// log.println(procHdl.getOutputText()); // log.println(procHdl.getOutputText());
@@ -142,40 +152,93 @@ public class CheckModuleAPI extends ComplexTestCase {
// log.println(procHdl.getErrorText()); // log.println(procHdl.getErrorText());
// log.println("<--- Error output of dmake:"); // 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..."); 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");
private void addIfQaUnoApiFolderExist(File srcRoot, ArrayList moduleNames) { if (!bNoOffice)
{
if (doesQaUnoApiFolderExist(srcRoot)) { try
moduleNames.add(srcRoot.getName()); {
officeProvider.closeExistingOffice(param, true);
}
catch (java.lang.UnsatisfiedLinkError exception)
{
log.println("Office seems not to be running");
}
} }
} }
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;
private boolean doesQaUnoApiFolderExist(File srcRoot) { 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(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 FolderFilter qaFilter = new FolderFilter("qa");
final File[] qaTree = srcRoot.listFiles(qaFilter); final File[] qaTree = srcRoot.listFiles(qaFilter);
if (qaTree != null) { if (qaTree != null)
for (int j = 0; j < qaTree.length; j++) { {
for (int j = 0; j < qaTree.length; j++)
{
final File qaFolder = qaTree[j]; final File qaFolder = qaTree[j];
final FolderFilter apiFilter = new FolderFilter("unoapi"); final FolderFilter apiFilter = new FolderFilter("unoapi");
final File[] apiTree = qaFolder.listFiles(apiFilter); final File[] apiTree = qaFolder.listFiles(apiFilter);
if (apiTree != null && apiTree.length > 0) { if (apiTree != null && apiTree.length > 0)
{
return true; return true;
} }
} }
} }
return false; return false;
} }
*/
private String[] getAllModuleCommand() { private String[] getAllModuleCommand()
{
String[] checkModules; String[] checkModules;
final String[] names = getModulesFromSourceRoot(); final String[] names = getModulesFromSourceRoot();
@@ -184,45 +247,75 @@ public class CheckModuleAPI extends ComplexTestCase {
return checkModules; return checkModules;
} }
private String[] getCheckModuleCommand(String[] names) { private String[] getCheckModuleCommand(String[] names)
{
String[] checkModules; String[] checkModules;
checkModules = new String[names.length]; 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 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(".")) + ")"; checkModules[i] = "checkModule(" + names[i].substring(0, names[i].indexOf(".")) + ")";
} else { }
else
{
checkModules[i] = "checkModule(" + names[i] + ")"; checkModules[i] = "checkModule(" + names[i] + ")";
} }
} }
return checkModules; return checkModules;
} }
private String[] getCommands(String sUnoapi) { private String[] getDmakeCommands(String sUnoapi)
{
String[] cmdLines = null; String[] cmdLines = null;
final String platform = (String) param.get(PropertyName.OPERATING_SYSTEM); final String platform = (String) param.get(PropertyName.OPERATING_SYSTEM);
log.println("prepare command for platform " + platform); log.println("prepare command for platform " + platform);
if (platform.equals(PropertyName.WNTMSCI)){ if (platform.equals(PropertyName.WNTMSCI))
if (param.getBool(PropertyName.CYGWIN)){ {
cmdLines = new String[]{"cd `cygpath '" + sUnoapi.replaceAll("\\\\", "\\\\\\\\")+ "'`", "dmake"}; if (param.getBool(PropertyName.CYGWIN))
} else{ {
cmdLines = new String[]{"cdd " + sUnoapi, "dmake"}; // cygwin stuff
cmdLines = new String[]
{
"cd `cygpath '" + sUnoapi.replaceAll("\\\\", "\\\\\\\\") + "'`",
"dmake"
};
} }
} else { else
cmdLines = new String[]{"cd " + sUnoapi, "dmake"}; {
// old 4NT
cmdLines = new String[]
{
"cdd " + sUnoapi,
"dmake"
};
} }
}
else
{
// unix
cmdLines = new String[]
{
"cd " + sUnoapi,
"dmake"
};
}
return cmdLines; return cmdLines;
} }
private String[] getCwsModuleCommand() { private String[] getCwsModuleCommand()
{
String[] checkModules; String[] checkModules;
final String version = (String) param.get(PropertyName.VERSION); final String version = (String) param.get(PropertyName.VERSION);
String[] names = null; String[] names = null;
if (version.startsWith("cws_")) { if (version.startsWith("cws_"))
try { {
try
{
// cws version: all added modules must be tested // cws version: all added modules must be tested
final String cws = version.substring(4, version.length()); final String cws = version.substring(4, version.length());
final CwsDataExchangeImpl cde = new CwsDataExchangeImpl(cws, param, log); final CwsDataExchangeImpl cde = new CwsDataExchangeImpl(cws, param, log);
@@ -230,18 +323,27 @@ public class CheckModuleAPI extends ComplexTestCase {
final ArrayList moduleNames = new ArrayList(); final ArrayList moduleNames = new ArrayList();
Iterator iterator = addedModules.iterator(); Iterator iterator = addedModules.iterator();
while (iterator.hasNext()) { while (iterator.hasNext())
final File sourceRoot = new File(mSRC_ROOT + File.separator + (String) iterator.next()); {
addIfQaUnoApiFolderExist(sourceRoot, moduleNames); 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]); names = (String[]) moduleNames.toArray(new String[0]);
} catch (ParameterNotFoundException ex) { }
catch (ParameterNotFoundException ex)
{
this.failed(ex.toString(), false); this.failed(ex.toString(), false);
} }
} else { }
else
{
// major version: all modules must be tested // major version: all modules must be tested
names = getModulesFromSourceRoot(); names = getModulesFromSourceRoot();
} }
@@ -250,53 +352,70 @@ public class CheckModuleAPI extends ComplexTestCase {
return checkModules; return checkModules;
} }
private String[] getDefinedModuleCommand(String module) { private String[] getDefinedModuleCommand(String module)
{
String[] checkModules = null; String[] checkModules = null;
// list of modules to test: (sw,sc,sd) // list of modules to test: (sw,sc,sd)
if (module.indexOf(",") != -1) { if (module.indexOf(",") != -1)
{
final String[] names = module.split(","); final String[] names = module.split(",");
checkModules = new String[names.length]; 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(); final String moduleName = names[i].trim();
File sourceRoot = new File(mSRC_ROOT + File.separator + moduleName); // File sourceRoot = new File(mSRC_ROOT + File.separator + moduleName);
if (!sourceRoot.exists()) { // if (!sourceRoot.exists())
sourceRoot = new File(mSRC_ROOT + File.separator + moduleName + ".lnk"); // {
} // sourceRoot = new File(mSRC_ROOT + File.separator + moduleName + ".lnk");
// }
if (doesQaUnoApiFolderExist(sourceRoot)) { if (doesQaUnoApiFolderExist(mSRC_ROOT, moduleName))
{
checkModules[i] = "checkModule(" + moduleName + ")"; checkModules[i] = "checkModule(" + moduleName + ")";
} }
} }
} else { }
File sourceRoot = new File(mSRC_ROOT + File.separator + module); else
if (!sourceRoot.exists()) { {
sourceRoot = new File(mSRC_ROOT + File.separator + module + ".lnk"); // File sourceRoot = new File(mSRC_ROOT + File.separator + module);
} // if (!sourceRoot.exists())
if (doesQaUnoApiFolderExist(sourceRoot)) { // {
checkModules = new String[]{"checkModule(" + module + ")"}; // sourceRoot = new File(mSRC_ROOT + File.separator + module + ".lnk");
// }
if (doesQaUnoApiFolderExist(mSRC_ROOT, module))
{
checkModules = new String[]
{
"checkModule(" + module + ")"
};
} }
} }
return checkModules; return checkModules;
} }
private String getModulePath(String module) { private String getModulePath(String module)
{
String sUnoapi = null; // String sUnoapi = null;
final String sep = System.getProperty("file.separator"); // final String sep = System.getProperty("file.separator");
final File srcRoot = new File(mSRC_ROOT); // final File srcRoot = new File(mSRC_ROOT);
final FolderFilter qaFilter = new FolderFilter(module); // final FolderFilter qaFilter = new FolderFilter(module);
final File[] moduleTree = srcRoot.listFiles(qaFilter); // final File[] moduleTree = srcRoot.listFiles(qaFilter);
if (moduleTree != null) { // if (moduleTree != null)
if (mDebug) { // {
log.println("moduleTree length:" + moduleTree.length); // if (mDebug)
log.println("moduleTree: " + moduleTree[0].getAbsolutePath()); // {
} // log.println("moduleTree length:" + moduleTree.length);
if (moduleTree != null) { // log.println("moduleTree: " + moduleTree[0].getAbsolutePath());
sUnoapi = moduleTree[0].getAbsolutePath() + sep + "qa" + sep + "unoapi"; // }
} // if (moduleTree != null)
} // {
// sUnoapi = moduleTree[0].getAbsolutePath() + sep + "qa" + sep + "unoapi";
// }
// }
String sUnoapi = getQaUnoApiPath(mSRC_ROOT, module);
return sUnoapi; return sUnoapi;
} }
@@ -314,35 +433,39 @@ public class CheckModuleAPI extends ComplexTestCase {
* sfx -> sfx2 * sfx -> sfx2
* sm -> starmath * 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"); aModuleHashMap.put("fwk", "framework");
modulez.put("fwl", "framework"); aModuleHashMap.put("fwl", "framework");
modulez.put("sch", "chart2"); aModuleHashMap.put("sch", "chart2");
modulez.put("sysmgr1", "configmgr"); aModuleHashMap.put("sysmgr1", "configmgr");
modulez.put("cfgmag2", "configmgr"); aModuleHashMap.put("cfgmag2", "configmgr");
modulez.put("lnn", "lingu"); aModuleHashMap.put("lnn", "lingu");
modulez.put("lng", "linguistic"); aModuleHashMap.put("lng", "linguistic");
modulez.put("sfx", "sfx2"); aModuleHashMap.put("sfx", "sfx2");
modulez.put("sm", "starmath"); aModuleHashMap.put("sm", "starmath");
// it could the that the parameter looks like "fwk,fwl". This results in double "famework,framework". // 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" // The following loop correct this to only one "framework"
final Set keys = modulez.keySet(); final Set keys = aModuleHashMap.keySet();
final Iterator iterator = keys.iterator(); final Iterator iterator = keys.iterator();
while (iterator.hasNext()) { while (iterator.hasNext())
{
final String key = (String) iterator.next(); 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); module = module.replaceAll(key, value);
final int count = module.split(value).length; final int count = module.split(value).length;
if (count > 2) { if (count > 2)
for (int i = 2; i < count; i++) { {
for (int i = 2; i < count; i++)
{
module.replaceFirst("," + value, ""); module.replaceFirst("," + value, "");
} }
@@ -351,33 +474,41 @@ public class CheckModuleAPI extends ComplexTestCase {
return module; return module;
} }
private boolean verifyOutput(String output) { private boolean verifyOutput(String output)
{
log.println("verify output..."); log.println("verify output...");
boolean ok = false; boolean ok = false;
final String[] outs = output.split("\n"); 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]; 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); 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; ok = true;
log.println("Module passed OK"); log.println("Module passed OK");
} else { }
else
{
log.println("Module passed FAILED"); log.println("Module passed FAILED");
} }
} }
} }
if (!ok) { if (!ok)
{
log.println("ERROR: could not find '0 of [0-9]+? tests failed' in output"); log.println("ERROR: could not find '0 of [0-9]+? tests failed' in output");
} }
return ok; return ok;
} }
private String[] getModulesFromSourceRoot() { private String[] getModulesFromSourceRoot()
{
log.println("**** run module tests over all modules ****"); log.println("**** run module tests over all modules ****");
log.println("search for qa/unoapi foldres in all modules based in "); 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 sourceRoot = new File(mSRC_ROOT);
final File[] sourceTree = sourceRoot.listFiles(); 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]; 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]); final String[] names = (String[]) moduleNames.toArray(new String[0]);
@@ -409,7 +546,8 @@ public class CheckModuleAPI extends ComplexTestCase {
* <li>'auto' to check only modules which are added to the ChildWorkSpace</li> * <li>'auto' to check only modules which are added to the ChildWorkSpace</li>
* </ul> * </ul>
*/ */
public void module(String module) { public void module(String module)
{
String[] checkModules; String[] checkModules;
final ComplexDescGetter desc = new ComplexDescGetter(); final ComplexDescGetter desc = new ComplexDescGetter();
@@ -420,30 +558,38 @@ public class CheckModuleAPI extends ComplexTestCase {
all: check all modules which contains a qa/unoapi folder 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 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(); checkModules = getAllModuleCommand();
} else if (module.equals("auto")) { }
else if (module.equals("auto"))
{
checkModules = getCwsModuleCommand(); checkModules = getCwsModuleCommand();
} else { }
else
{
module = getTranslatedNames(module); module = getTranslatedNames(module);
checkModules = getDefinedModuleCommand(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, entry = desc.createTestDesc("complex.unoapi.CheckModuleAPI", "complex.unoapi.CheckModuleAPI", checkModules,
log); log);
final java_complex complex = new java_complex(); final java_complex complex = new java_complex();
log.println("********** start test *************"); 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 *************"); log.println("********** end test *************");
assure("CheckModuleAPI.module(" + module + ") PASSED.FAILED", result); 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; 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); final String version = (String) param.get(PropertyName.VERSION);
if (version.startsWith("cws_")) { if (version.startsWith("cws_"))
try { {
try
{
// cws version: all added modules must be tested // cws version: all added modules must be tested
final String cws = version.substring(4, version.length()); final String cws = version.substring(4, version.length());
final CwsDataExchangeImpl cde = new CwsDataExchangeImpl(cws, param, log); final CwsDataExchangeImpl cde = new CwsDataExchangeImpl(cws, param, log);
cde.setUnoApiCwsStatus(status); cde.setUnoApiCwsStatus(status);
} catch (ParameterNotFoundException ex) { }
catch (ParameterNotFoundException ex)
{
log.println("ERROR: could not wirte status to EIS database: " + ex.toString()); log.println("ERROR: could not wirte status to EIS database: " + ex.toString());
} }
} }
} }
} }
public String[] getTestMethodNames() { public String[] getTestMethodNames()
return new String[]{"module(all)"}; {
return new String[]
{
"module(all)"
};
} }
class FolderFilter implements FileFilter { // class _FolderFilter implements FileFilter
// {
private String mFolderName; //
// private String mFolderName;
public FolderFilter(String folderName) { //
mFolderName = folderName; // public FolderFilter(String folderName)
} // {
// mFolderName = folderName;
public boolean accept(File pathname) { // }
//
boolean found = false; // public boolean accept_(File pathname)
if (pathname.isDirectory()) { // {
if (pathname.getName().equals(mFolderName)) { //
found = true; // boolean found = false;
} else if (pathname.getName().equals(mFolderName + ".lnk")) { // if (pathname.isDirectory())
found = true; // {
} // if (pathname.getName().equals(mFolderName))
} // {
return found; // found = true;
} // }
} // else if (pathname.getName().equals(mFolderName + ".lnk"))
// {
// found = true;
// }
// }
// return found;
// }
// }
} }

View File

@@ -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
* <http://www.openoffice.org/license.html>
* 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 <code>ifc.qadevooo._SelfTest</code>
* interface methods:
* <ul>
* <li><code>testmethod()</code></li>
* </ul> <p>
*
*/
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() ;
}
}

View File

@@ -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
* <http://www.openoffice.org/license.html>
* 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;
}
}