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,15 +59,22 @@ 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) {
private lib.TestParameters m_aParams;
private AppProvider m_aOffice;
public boolean executeTest(lib.TestParameters param)
{
m_aParams = param;
dcl = new DynamicClassLoader();
DescGetter dg = new APIDescGetter();
@@ -79,23 +86,24 @@ public class java_fat implements TestBase {
logging = param.getBool("LoggingIsActive");
keepdocument = param.getBool("KeepDocument");
newOffice = param.getBool(util.PropertyName.NEW_OFFICE_INSTANCE);
if (keepdocument) {
if (keepdocument)
{
System.setProperty("KeepDocument", "true");
}
if (ExclusionFile != null) {
if (ExclusionFile != null)
{
exclusions = getExclusionList(ExclusionFile, debug);
}
//get Job-Descriptions
System.out.println("Getting Descriptions for Job: " + job);
DescEntry[] entries = dg.getDescriptionFor(job,
(String) param.get(
"DescriptionPath"),
debug);
String sDescriptionPath = (String) param.get("DescriptionPath");
DescEntry[] entries = dg.getDescriptionFor(job, sDescriptionPath, debug);
System.out.println();
// System.out.println();
if (entries == null) {
if (entries == null)
{
System.out.println("Couldn't get Description for Job: " + job);
return false;
@@ -110,24 +118,29 @@ public class java_fat implements TestBase {
// System.exit(-1);
// }
AppProvider office = startOffice(param);
m_aOffice = startOffice(param);
boolean firstRun = true;
for (int l = 0; l < entries.length; l++) {
if (entries[l] == null) {
for (int l = 0; l < entries.length; l++)
{
if (entries[l] == null)
{
continue;
}
if (entries[l].hasErrorMsg) {
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);
}
@@ -138,7 +151,8 @@ public class java_fat implements TestBase {
XMultiServiceFactory msf = (XMultiServiceFactory) param.getMSF();
if (msf == null) {
if (msf == null)
{
retValue = false;
continue;
@@ -153,18 +167,23 @@ public class java_fat implements TestBase {
TestCase tCase = null;
try {
tCase = (TestCase) dcl.getInstance("mod._" +
entry.entryName);
} catch (java.lang.IllegalArgumentException ie) {
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) {
}
catch (java.lang.NoClassDefFoundError ie)
{
entry.ErrorMsg = ie.getMessage();
entry.hasErrorMsg = true;
}
if (tCase == null) {
if (tCase == null)
{
Summarizer.summarizeDown(entry, entry.ErrorMsg);
LogWriter sumObj = OutProducerFactory.createOutProducer(param);
@@ -175,46 +194,49 @@ public class java_fat implements TestBase {
continue;
}
if (debug) {
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"));
LogWriter log = (LogWriter) dcl.getInstance((String) param.get("LogWriter"));
log.initialize(entry, logging);
entry.UserDefinedParams = param;
TestEnvironment tEnv = null;
try {
try
{
tCase.setLogWriter((PrintWriter) log);
tCase.initializeTestCase(param);
tEnv = tCase.getTestEnvironment(param);
} catch (Exception e) {
System.out.println("Exception while creating " +
tCase.getObjectName());
}
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());
}
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());
}
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 (tEnv == null)
{
Summarizer.summarizeDown(entry, "Couldn't create " + tCase.getObjectName());
LogWriter sumObj = OutProducerFactory.createOutProducer(param);
entry.UserDefinedParams = param;
@@ -226,39 +248,34 @@ public class java_fat implements TestBase {
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");
for (int j = 0; j < entry.SubEntryCount; j++)
{
DescEntry aSubEntry = entry.SubEntries[j];
if (!aSubEntry.isToTest)
{
Summarizer.summarizeDown(aSubEntry, "not part of the job");
continue;
}
if ((exclusions != null) && (exclusions.contains(entry.SubEntries[j].longName))) {
Summarizer.summarizeDown(entry.SubEntries[j],
"known issue");
if ((exclusions != null) && (exclusions.contains(aSubEntry.longName)))
{
Summarizer.summarizeDown(aSubEntry, "known issue");
continue;
}
System.out.println("running: '" + entry.SubEntries[j].entryName + "'");
System.out.println("running: '" + aSubEntry.entryName + "'");
LogWriter ifclog = (LogWriter) dcl.getInstance(
(String) param.get("LogWriter"));
LogWriter ifclog = (LogWriter) dcl.getInstance( (String) param.get("LogWriter"));
ifclog.initialize(entry.SubEntries[j], logging);
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);
}
ifclog.initialize(aSubEntry, logging);
aSubEntry.UserDefinedParams = param;
aSubEntry.Logger = ifclog;
if ((tEnv == null) || tEnv.isDisposed())
{
closeExistingOffice();
tEnv = getEnv(entry, param);
}
@@ -268,66 +285,73 @@ public class java_fat implements TestBase {
// run the interface test twice if it failed.
int countInterfaceTestRun = 0;
boolean finished = false;
while (!finished) {
try {
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);
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) {
if (countInterfaceTestRun < 2)
{
finished = false;
} else {
Summarizer.summarizeDown(entry.SubEntries[j],
e.toString() + ".FAILED");
}
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]);
aSubEntry.UserDefinedParams = param;
sumIfc.initialize(aSubEntry, logging);
sumIfc.summary(aSubEntry);
}
try {
if (!keepdocument) {
try
{
if (!keepdocument)
{
tCase.cleanupTestCase(param);
}
} catch (Exception e) {
}
catch (Exception e)
{
System.out.println("couldn't cleanup");
} catch (java.lang.NoClassDefFoundError e) {
}
catch (java.lang.NoClassDefFoundError e)
{
System.out.println("couldn't cleanup");
}
@@ -339,36 +363,31 @@ public class java_fat implements TestBase {
sumObj.summary(entry);
}
if (entries.length > 1) {
if (entries.length > 0)
{
System.out.println();
int counter = 0;
System.out.println(
"Failures that appeared during scenario execution:");
System.out.println("Failures that appeared during scenario execution:");
for (int i = 0; i < entries.length; i++) {
if (!entries[i].State.endsWith("OK")) {
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);
System.out.println(counter + " of " + entries.length + " tests failed");
}
closeExistingOffice();
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,16 +408,21 @@ public class java_fat implements TestBase {
//
// param.put("ServiceFactory", msf);
AppProvider office = startOffice(param);
// AppProvider office = startOffice(param);
TestCase tCase = null;
try {
try
{
tCase = (TestCase) dcl.getInstance("mod._" + entry.entryName);
} catch (java.lang.IllegalArgumentException ie) {
}
catch (java.lang.IllegalArgumentException ie)
{
entry.ErrorMsg = ie.getMessage();
entry.hasErrorMsg = true;
} catch (java.lang.NoClassDefFoundError ie) {
}
catch (java.lang.NoClassDefFoundError ie)
{
entry.ErrorMsg = ie.getMessage();
entry.hasErrorMsg = true;
}
@@ -407,36 +431,27 @@ public class java_fat implements TestBase {
entry.UserDefinedParams = param;
LogWriter log = (LogWriter) dcl.getInstance(
(String) param.get("LogWriter"));
LogWriter log = (LogWriter) dcl.getInstance((String) param.get("LogWriter"));
log.initialize(entry, logging);
tCase.setLogWriter((PrintWriter) log);
TestEnvironment tEnv = null;
try {
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) {
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");
if (ph != null) {
office.closeExistingOffice(param, true);
shortWait(5000);
}
closeExistingOffice();
entry.ErrorMsg = e.getMessage();
entry.hasErrorMsg = true;
@@ -445,49 +460,79 @@ public class java_fat implements TestBase {
return tEnv;
}
protected void shortWait(int millis) {
try {
private void closeExistingOffice()
{
helper.ProcessHandler ph = (helper.ProcessHandler) m_aParams.get("AppProvider");
if (ph != null)
{
m_aOffice.closeExistingOffice(m_aParams, true);
shortWait(5000);
}
}
private void shortWait(int millis)
{
try
{
Thread.sleep(millis);
} catch (java.lang.InterruptedException ie) {
}
catch (java.lang.InterruptedException ie)
{
}
}
protected Vector getExclusionList(String url, boolean debug) {
private Vector getExclusionList(String url, boolean debug)
{
Vector entryList = new Vector();
String line = "#";
BufferedReader exclusion = null;
try {
try
{
exclusion = new BufferedReader(new FileReader(url));
} catch (java.io.FileNotFoundException fnfe) {
if (debug) {
}
catch (java.io.FileNotFoundException fnfe)
{
if (debug)
{
System.out.println("Couldn't find file " + url);
}
return entryList;
}
while (line != null) {
try {
if (!line.startsWith("#") && (line.length() > 1)) {
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");
}
catch (java.io.IOException ioe)
{
if (debug)
{
System.out.println("Exception while reading exclusion list");
}
return entryList;
}
}
try {
try
{
exclusion.close();
} catch (java.io.IOException ioe) {
if (debug) {
}
catch (java.io.IOException ioe)
{
if (debug)
{
System.out.println("Couldn't close file " + url);
}
@@ -499,30 +544,33 @@ public class java_fat implements TestBase {
private TestResult executeInterfaceTest(
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);
}
private AppProvider startOffice(lib.TestParameters param) {
private AppProvider startOffice(lib.TestParameters param)
{
if (dcl == null) {
if (dcl == null)
{
dcl = new DynamicClassLoader();
}
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.");
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){
if (msf != null)
{
param.put("ServiceFactory", msf);
}

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
* 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;

View File

@@ -42,7 +42,6 @@ import java.util.StringTokenizer;
import share.DescEntry;
import share.DescGetter;
/**
* This is the Office-API specific DescGetter<br>
* <br>
@@ -68,11 +67,11 @@ import share.DescGetter;
* -sce sw.SwXBodyText,sw.SwXBookmark<br>
* runs the module test of <B>Sw.SwXBodyText</B> and <B>sw.SwXBookmark</B><br>
*/
public class APIDescGetter extends DescGetter
{
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 {
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);
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());
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<scenario.length;i++) {
for (int i = 0; i < scenario.length; i++)
{
entries[i] = getDescriptionForSingleJob(
scenario[i].substring(3).trim(), descPath, debug);
}
if (job.equals("listall")) {
if (job.equals("listall"))
{
util.dbg.printArray(scenario);
System.exit(0);
}
return entries;
}
if (job.startsWith("-sce")) {
if (job.startsWith("-sce"))
{
job = job.substring(5, job.length()).trim();
File sceFile = new File(job);
if (sceFile.exists())
{
return getScenario(job, descPath, debug);
else {
}
else
{
//look the scenarion like this? :
// sw.SwXBodyText,sw.SwXTextCursor
ArrayList subs = getSubObjects(job);
DescEntry[] entries = new DescEntry[subs.size()];
for (int i=0; i<subs.size(); i++){
for (int i = 0; i < subs.size(); i++)
{
entries[i] = getDescriptionForSingleJob(
(String)subs.get(i), descPath, debug);
(String) subs.get(i), descPath, debug);
}
return entries;
}
} else {
}
else
{
return null;
}
}
protected DescEntry getDescriptionForSingleJob(String job, String descPath,
boolean debug) {
boolean debug)
{
boolean isSingleInterface = job.indexOf("::") > 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,90 +245,109 @@ 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(";");
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("#"));
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 (meth_name.endsWith("()")) {
methDesc.EntryType = "method";
entryType = "interface";
} else {
methDesc.EntryType = "property";
entryType = "service";
}
// String ifc_name = line.substring(line.indexOf(";") + 2, line.lastIndexOf(";") - 1);
// String meth_name = line.substring(line.lastIndexOf(";") + 2, line.length() - 1);
methDesc.entryName = meth_name;
methDesc.isToTest = true;
DescEntry methDesc = createDescEntry(meth_name, ifc_name, parent);
meth_names.add(methDesc);
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;
if (!ifc_name.equals(old_ifc_name)) {
if (ifcDesc != null) {
ifcDesc.SubEntries = getDescArray(
meth_names.toArray());
if (!ifc_name.equals(old_ifc_name))
{
if (ifcDesc != null)
{
ifcDesc.SubEntries = getDescArray(meth_names.toArray());
ifcDesc.SubEntryCount = meth_names.size();
//mark service/interface as optional if all methods/properties are optional
boolean allOptional = true;
for (int k = 0; k < ifcDesc.SubEntryCount; k++) {
if (!ifcDesc.SubEntries[k].isOptional) {
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;
}
@@ -302,10 +359,10 @@ public class APIDescGetter extends DescGetter {
ifcDesc.isToTest = true;
old_ifc_name = ifc_name;
if (ifc_name.indexOf("#optional") > 0) {
if (ifc_name.indexOf("#optional") > 0)
{
ifcDesc.isOptional = true;
ifc_name = ifc_name.substring(0,
ifc_name.indexOf("#"));
ifc_name = ifc_name.substring(0, ifc_name.indexOf("#"));
}
StringTokenizer st = new StringTokenizer(ifc_name, ":");
@@ -313,16 +370,20 @@ public class APIDescGetter extends DescGetter {
int count = 3;
if (ifc_name.startsWith("drafts")) {
if (ifc_name.startsWith("drafts"))
{
count = 4;
}
for (int i = 0; st.hasMoreTokens(); i++) {
for (int i = 0; st.hasMoreTokens(); i++)
{
String token = st.nextToken();
// skipping (drafts.)com.sun.star
if (i >= count) {
if (!st.hasMoreTokens()) {
if (i >= count)
{
if (!st.hasMoreTokens())
{
// inserting '_' before the last token
token = "_" + token;
}
@@ -333,13 +394,12 @@ public class APIDescGetter extends DescGetter {
ifcDesc.EntryType = entryType;
ifcDesc.entryName = "ifc" + className;
ifcDesc.longName = parent.entryName + "::" +
ifc_name;
ifcDesc.longName = parent.entryName + "::" + ifc_name;
}
meth_names.add(methDesc);
}
} 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,9 +506,12 @@ 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;
@@ -404,30 +519,37 @@ public class APIDescGetter extends DescGetter {
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 + "'");
}
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,30 +594,29 @@ 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/" +
InputStream input = this.getClass().getResourceAsStream("/objdsc/" +
module +
"/" +
entry);
@@ -501,11 +628,14 @@ public class APIDescGetter extends DescGetter {
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 + "'");
@@ -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,7 +690,8 @@ 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 + "'");
}
@@ -562,15 +699,18 @@ public class APIDescGetter extends DescGetter {
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 + "'");
}
@@ -579,9 +719,12 @@ public class APIDescGetter extends DescGetter {
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<modules.length;i++) {
if (! isUnusedModule(modules[i])) {
File moduleDir = new File(descPath+System.getProperty("file.separator")+modules[i]);
if (moduleDir.exists()) {
for (int i = 0; i < modules.length; i++)
{
if (!isUnusedModule(modules[i]))
{
File moduleDir = new File(descPath + System.getProperty("file.separator") + modules[i]);
if (moduleDir.exists())
{
String[] components = moduleDir.list();
for (int j=0;j<components.length;j++) {
if (components[j].endsWith(".csv")) {
for (int j = 0; j < components.length; j++)
{
if (components[j].endsWith(".csv"))
{
String toAdd = getComponentForString(components[j], modules[i]);
toAdd = "-o "+modules[i]+"."+toAdd;
toAdd = "-o " + modules[i] + "." + toAdd;
componentList.add(toAdd);
}
}
@@ -676,7 +845,8 @@ public class APIDescGetter extends DescGetter {
String[] scenario = new String[componentList.size()];
Collections.sort(componentList);
for (int i = 0; i < componentList.size(); i++) {
for (int i = 0; i < componentList.size(); i++)
{
scenario[i] = (String) componentList.get(i);
}
@@ -684,37 +854,44 @@ public class APIDescGetter extends DescGetter {
}
protected String[] getScenarioFromClassPath(String job, boolean debug) {
protected String[] getScenarioFromClassPath(String job, boolean debug)
{
String subdir = "/";
if (!job.equals("unknown") && !job.equals("listall")) {
if (!job.equals("unknown") && !job.equals("listall"))
{
subdir += job;
}
java.net.URL url = this.getClass().getResource("/objdsc" + subdir);
if (url == null) {
if (url == null)
{
return null;
}
ArrayList scenarioList = new ArrayList();
try {
try
{
java.net.URLConnection con = url.openConnection();
if (con instanceof java.net.JarURLConnection) {
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()) {
while (e.hasMoreElements())
{
String entry = e.nextElement().toString();
if (entry.startsWith("objdsc" + subdir) &&
(entry.indexOf("CVS") < 0) &&
!entry.endsWith("/")) {
!entry.endsWith("/"))
{
int startMod = entry.indexOf("/");
int endMod = entry.lastIndexOf("/");
String module = entry.substring(startMod + 1, endMod);
@@ -723,28 +900,33 @@ public class APIDescGetter extends DescGetter {
entry.length()),
module);
if (!isUnusedModule(module)) {
if (!isUnusedModule(module))
{
scenarioList.add("-o " + module + "." +
component);
}
}
}
}
} catch (java.io.IOException e) {
}
catch (java.io.IOException e)
{
e.printStackTrace();
}
String[] scenario = new String[scenarioList.size()];
Collections.sort(scenarioList);
for (int i = 0; i < scenarioList.size(); i++) {
for (int i = 0; i < scenarioList.size(); i++)
{
scenario[i] = (String) scenarioList.get(i);
}
return scenario;
}
protected String getComponentForString(String full, String module) {
protected String getComponentForString(String full, String module)
{
String component = "";
@@ -755,7 +937,8 @@ public class APIDescGetter extends DescGetter {
int lastdot = full.lastIndexOf(".");
component = full.substring(lastdot + 1, full.length());
if (module.equals("file") || module.equals("xmloff")) {
if (module.equals("file") || module.equals("xmloff"))
{
String withoutComponent = full.substring(0, lastdot);
int preLastDot = withoutComponent.lastIndexOf(".");
component = withoutComponent.substring(preLastDot + 1,
@@ -766,7 +949,8 @@ public class APIDescGetter extends DescGetter {
return component;
}
protected boolean isUnusedModule(String moduleName) {
protected boolean isUnusedModule(String moduleName)
{
ArrayList removed = new ArrayList();
removed.add("acceptor");
removed.add("brdgfctr");

View File

@@ -1,5 +1,5 @@
/*
*************************************************************************
*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@@ -43,7 +43,8 @@ import util.utils;
* Implementaion of the interface CwsDataExchange
* @see share.CwsDataExchange
*/
public class CwsDataExchangeImpl implements CwsDataExchange {
public class CwsDataExchangeImpl implements CwsDataExchange
{
private final String cwsName;
private final TestParameters param;
@@ -51,7 +52,8 @@ public class CwsDataExchangeImpl implements CwsDataExchange {
private final BuildEnvTools bet;
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.param = param;
this.log = log;
@@ -59,15 +61,22 @@ public class CwsDataExchangeImpl implements CwsDataExchange {
mDebug = param.getBool(PropertyName.DEBUG_IS_ACTIVE);
}
public ArrayList getModules() {
public ArrayList getModules()
{
// the cwstouched command send its version information to StdErr.
// A piping from StdErr to SdtOut the tcsh does not support.
// To find the output easily the echo command is used
final String[] commands = {"echo cwstouched starts here", "cwstouched", "echo cwstouched ends here"};
final String[] commands =
{
"echo cwstouched starts here",
"cwstouched",
"echo cwstouched ends here"
};
final ProcessHandler procHdl = bet.runCommandsInEnvironmentShell(commands, null, 20000);
if (mDebug) {
if (mDebug)
{
log.println("---> 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<String> moduleNames = new ArrayList<String>();
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) {
if (line.startsWith("cwstouched ends here"))
{
bStart = false;
continue;
}
if (bStart && line.length() > 1)
{
moduleNames.add(line);
}
if (line.startsWith("cwstouched starts here")) {
start = true;
}
}
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();
}
}

View File

@@ -366,17 +366,20 @@ public class ProcessHandler
{
ow = (OfficeWatcher) param.get(PropertyName.OFFICE_WATCHER);
}
while (!this.isFinished() && changedText)
{
count++;
if (ow != null)
{
ow.ping();
}
dbg("runCommand: waiting " + mTimeOut / 1000 + " seconds while command execution is ongoing... " + count);
shortWait(mTimeOut);
int hangcheck = 10;
while (!this.isFinished() && changedText)
{
count++;
// dbg("runCommand: waiting " + mTimeOut / 1000 + " seconds while command execution is ongoing... " + count);
// shortWait(mTimeOut);
// shortWait(2000); // wait 2 seconds.
//waitFor(mTimeOut);
waitFor(2000, false); // wait but don't kill
if (ow != null)
{
@@ -385,15 +388,20 @@ 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)
{
String sOutputText = getOutputText();
if (sOutputText.length() == memText.length())
{
changedText = false;
dbg("runCommand Could not detect changes in output stream!!!");
// dbg("runCommand Could not detect changes in output stream!!!");
}
hangcheck = 10;
memText = this.getOutputText();
}
}
}
if (!this.isFinished())
{
@@ -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();
@@ -579,6 +584,11 @@ public class ProcessHandler
* (exit code doesn't affect to this result).
*/
public boolean waitFor(long timeout)
{
return waitFor(timeout, true);
}
private boolean waitFor(long timeout, boolean bKillProcessAfterTimeout)
{
if (isFinished())
{
@@ -638,12 +648,15 @@ public class ProcessHandler
}
}
if (bKillProcessAfterTimeout == true)
{
if (!isFinished)
{
log.println("Going to destroy the process!!");
m_aProcess.destroy();
log.println("Process has been destroyed!");
}
}
// Removed as hung up in SDK test 'PathSettings'
// try {
// stdout.join();

View File

@@ -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,26 +143,31 @@ 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;
// 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);
System.out.println("checking : " + ifcName);
// defining a name of the class corresponding to the tested interface
// or service
@@ -174,13 +175,17 @@ public class MultiMethodTest {
testedClassName = getTestedClassName();
if (entry.EntryType.equals("service")) {
if (entry.EntryType.equals("service"))
{
testedClassName = "com.sun.star.beans.XPropertySet";
}
try {
try
{
testedClass = Class.forName(testedClassName);
} catch (ClassNotFoundException cnfE) {
}
catch (ClassNotFoundException cnfE)
{
cnfE.printStackTrace(log);
log.println("could not find a class : " + getTestedClassName());
@@ -190,49 +195,61 @@ public class MultiMethodTest {
// quering the tested interface from the tested object
XInterface tCase = tEnv.getTestObject();
Object oObj = UnoRuntime.queryInterface(
testedClass, 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;
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);
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<entry.SubEntryCount;i++) {
try {
executeMethod( entry.SubEntries[i].entryName );
} catch (Exception e){
log.println("Exception while checking: "+
entry.SubEntries[i].entryName+" : "+e.getMessage());
for (int i = 0; i < entry.SubEntryCount; i++)
{
DescEntry aSubEntry = entry.SubEntries[i];
try
{
executeMethod(aSubEntry.entryName);
}
catch (Exception e)
{
log.println("Exception while checking: " + aSubEntry.entryName + " : " + e.getMessage());
}
}
// to perform some stuff after all method tests
try {
try
{
after();
} catch (Exception e){}
}
catch (Exception e)
{
}
return tRes;
}
@@ -241,21 +258,23 @@ public class MultiMethodTest {
* Is called before calling method tests, but after initialization.
* Subclasses may override to perform actions before method tests.
*/
protected void before() {
protected void before()
{
}
/**
* Is called after calling method tests. Subclasses may override
* to perform actions after method tests.
*/
protected void after() {
protected void after()
{
}
/**
* @return the name of the interface or the service tested.
*/
protected String getTestedClassName() {
protected String getTestedClassName()
{
String clsName = this.getClass().getName();
int firstDot = clsName.indexOf(".");
@@ -263,13 +282,12 @@ public class MultiMethodTest {
String append = "com.sun.star.";
if (entry.longName.indexOf("::drafts::com::")>-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;k<entry.SubEntryCount;k++) {
entry.SubEntries[k].hasErrorMsg=true;
entry.SubEntries[k].ErrorMsg=msg;
if (entry.SubEntries[k].State.equals("UNKNOWN")) {
protected void setSubStates(String msg)
{
for (int k = 0; k < entry.SubEntryCount; k++)
{
entry.SubEntries[k].hasErrorMsg = true;
entry.SubEntries[k].ErrorMsg = msg;
if (entry.SubEntries[k].State.equals("UNKNOWN"))
{
entry.SubEntries[k].State = msg;
}
}
@@ -299,9 +321,12 @@ public class MultiMethodTest {
/**
* Checks if the <code>method</code> is optional in the service.
*/
protected boolean isOptional(String method) {
for (int k=0;k<entry.SubEntryCount;k++) {
if (entry.SubEntries[k].entryName.equals(method)) {
protected boolean isOptional(String method)
{
for (int k = 0; k < entry.SubEntryCount; k++)
{
if (entry.SubEntries[k].entryName.equals(method))
{
return entry.SubEntries[k].isOptional;
}
}
@@ -311,8 +336,9 @@ public class MultiMethodTest {
/**
* Checks if the <code>method</code> 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 <code>method</code> 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 <code>method</code> 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, <tt>null</tt> 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 <code>fieldName</code> of the subclass with
* <code>value</code>.
*
* @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);
}
}
}

View File

@@ -36,13 +36,14 @@ 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);
@@ -55,43 +56,56 @@ public abstract class DescGetter {
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 {
}
else
{
ArrayList subs = getSubInterfaces(job);
String partjob = job.substring(0, job.indexOf(",")).trim();
aEntry = getDescriptionForSingleJob(partjob, descPath,
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());
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,
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(),
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);
}
}

View File

@@ -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);

View File

@@ -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;
* </ul>
*
*/
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 <CODE>-noOffice true</CODE>
*/
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 {
// 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) {
}
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;
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 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) {
private String getModulePath(String module)
{
String sUnoapi = null;
final String sep = System.getProperty("file.separator");
final File srcRoot = new File(mSRC_ROOT);
// 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";
}
}
// 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 {
* <li>'auto' to check only modules which are added to the ChildWorkSpace</li>
* </ul>
*/
public void module(String module) {
public void module(String module)
{
String[] checkModules;
final ComplexDescGetter desc = new ComplexDescGetter();
@@ -420,16 +558,22 @@ 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);
@@ -437,13 +581,15 @@ public class CheckModuleAPI extends ComplexTestCase {
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;
// }
// }
}

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;
}
}