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

@ -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 {
officeProvider.closeExistingOffice(param, true);
} catch (java.lang.UnsatisfiedLinkError exception) {
log.println("Office seems not to be running");
}
}
private void addIfQaUnoApiFolderExist(File srcRoot, ArrayList moduleNames) {
if (doesQaUnoApiFolderExist(srcRoot)) {
moduleNames.add(srcRoot.getName());
// TODO: how to check if the office is not started with this process.
boolean bNoOffice = param.getBool("NoOffice");
if (!bNoOffice)
{
try
{
officeProvider.closeExistingOffice(param, true);
}
catch (java.lang.UnsatisfiedLinkError exception)
{
log.println("Office seems not to be running");
}
}
}
private 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,30 +558,38 @@ public class CheckModuleAPI extends ComplexTestCase {
all: check all modules which contains a qa/unoapi folder
auto: check all modules which contains a qa/unoapi folder except the module is not added
*/
if (module.equals("all")) {
if (module.equals("all"))
{
checkModules = getAllModuleCommand();
} else if (module.equals("auto")) {
}
else if (module.equals("auto"))
{
checkModules = getCwsModuleCommand();
} else {
}
else
{
module = getTranslatedNames(module);
checkModules = getDefinedModuleCommand(module);
}
if (checkModules != null && checkModules.length > 0) {
if (checkModules != null && checkModules.length > 0)
{
entry = desc.createTestDesc("complex.unoapi.CheckModuleAPI", "complex.unoapi.CheckModuleAPI", checkModules,
log);
log);
final java_complex complex = new java_complex();
log.println("********** start test *************");
final boolean result = complex.executeTest(param, new DescEntry[]{entry});
final boolean result = complex.executeTest(param, new DescEntry[] { entry });
log.println("********** end test *************");
assure("CheckModuleAPI.module(" + module + ") PASSED.FAILED", result);
} else {
log.println("No modules containing qa/unoapi foder found => OK");
}
else
{
log.println("No modules containing qa/unoapi folder found => OK");
state = true;
}
@ -451,48 +597,65 @@ public class CheckModuleAPI extends ComplexTestCase {
}
private void setUnoApiCwsStatus(boolean status) {
private void setUnoApiCwsStatus(boolean status)
{
if (!param.getBool(PropertyName.NO_CWS_ATTACH)) {
if (!param.getBool(PropertyName.NO_CWS_ATTACH))
{
final String version = (String) param.get(PropertyName.VERSION);
if (version.startsWith("cws_")) {
try {
if (version.startsWith("cws_"))
{
try
{
// cws version: all added modules must be tested
final String cws = version.substring(4, version.length());
final CwsDataExchangeImpl cde = new CwsDataExchangeImpl(cws, param, log);
cde.setUnoApiCwsStatus(status);
} catch (ParameterNotFoundException ex) {
}
catch (ParameterNotFoundException ex)
{
log.println("ERROR: could not wirte status to EIS database: " + ex.toString());
}
}
}
}
public String[] getTestMethodNames() {
return new String[]{"module(all)"};
public String[] getTestMethodNames()
{
return new String[]
{
"module(all)"
};
}
class FolderFilter implements FileFilter {
private String mFolderName;
public FolderFilter(String folderName) {
mFolderName = folderName;
}
public boolean accept(File pathname) {
boolean found = false;
if (pathname.isDirectory()) {
if (pathname.getName().equals(mFolderName)) {
found = true;
} else if (pathname.getName().equals(mFolderName + ".lnk")) {
found = true;
}
}
return found;
}
}
// class _FolderFilter implements FileFilter
// {
//
// private String mFolderName;
//
// public FolderFilter(String folderName)
// {
// mFolderName = folderName;
// }
//
// public boolean accept_(File pathname)
// {
//
// boolean found = false;
// if (pathname.isDirectory())
// {
// if (pathname.getName().equals(mFolderName))
// {
// found = true;
// }
// else if (pathname.getName().equals(mFolderName + ".lnk"))
// {
// found = true;
// }
// }
// return found;
// }
// }
}