update dev300-m58
[ooovba.git] / qadevOOo / runner / base / java_complex.java
blobc5ff6afc3adaa9cb1241b60361260db03938de14
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: java_complex.java,v $
10 * $Revision: 1.13.8.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 package base;
32 import complexlib.ComplexTestCase;
33 import util.DynamicClassLoader;
34 import share.DescGetter;
35 import stats.OutProducerFactory;
36 import helper.ComplexDescGetter;
37 import helper.AppProvider;
38 import helper.CfgParser;
39 import share.DescEntry;
40 import share.LogWriter;
41 import stats.Summarizer;
42 import lib.TestParameters;
43 import util.PropertyName;
45 /**
46 * Test base for executing a java complex test.
47 * @see base.TestBase
49 public class java_complex implements TestBase
52 /**
53 * This function executes the complex tests given as parameter "-o" or "TestJob". It querys for the correspond class
54 * and crates the JobDescription.
55 * @param param
56 * @return true of all tests run successfuly, esle false
58 public boolean executeTest(TestParameters param)
61 // is there an ini file for the complex tests defined?
62 String complexIniFileName = ((String) param.get("ComplexIni"));
63 if (complexIniFileName != null)
65 CfgParser ini = new CfgParser(complexIniFileName);
66 ini.getIniParameters(param);
69 // get the test job
70 String testJob = ((String) param.get("TestJob"));
72 DescGetter descGetter = new ComplexDescGetter();
73 // get the test jobs
74 DescEntry[] entries = descGetter.getDescriptionFor(testJob, null, true);
75 return executeTest(param, entries);
79 /**
80 * This function run the given DescEntry[] as ComplexTest
81 * @param param
82 * @param entries
83 * @return true of all tests run successfuly, esle false
85 public boolean executeTest(TestParameters param, DescEntry[] entries)
87 // is there an ini file for the complex tests defined?
88 String complexIniFileName = ((String) param.get("ComplexIni"));
89 if (complexIniFileName != null)
91 CfgParser ini = new CfgParser(complexIniFileName);
92 ini.getIniParameters(param);
95 DynamicClassLoader dcl = new DynamicClassLoader();
96 ComplexTestCase testClass = null;
97 boolean returnVal = true;
99 // the concept of the TimeOut depends on runner logs. If the runner log,
100 // for exmaple to start a test method, the timeout was restet. This is not
101 // while the test itself log something like "open docuent...".
102 // An property of complex test could be that it have only one test method
103 // which works for serveral minutes. Ih this case the TimeOut get not trigger
104 // and the office was killed.
105 // In complex tests just use "ThreadTimeOut" as timout.
107 // param.put("TimeOut", new Integer(0));
109 for (int i = 0; i < entries.length; i++)
112 if (entries[i] == null)
114 continue;
116 String iniName = entries[i].longName;
117 iniName = iniName.replace('.', '/');
118 CfgParser ini = new CfgParser(iniName + ".props");
119 ini.getIniParameters(param);
121 LogWriter log = (LogWriter) dcl.getInstance((String) param.get("LogWriter"));
123 AppProvider office = null;
124 if (!param.getBool("NoOffice"))
128 office = (AppProvider) dcl.getInstance("helper.OfficeProvider");
129 Object msf = office.getManager(param);
130 if (msf == null)
132 returnVal = false;
133 continue;
135 param.put("ServiceFactory", msf);
137 catch (IllegalArgumentException e)
139 office = null;
142 log.initialize(entries[i], param.getBool(PropertyName.LOGGING_IS_ACTIVE));
143 entries[i].Logger = log;
145 // create an instance
148 testClass = (ComplexTestCase) dcl.getInstance(entries[i].longName);
150 catch (java.lang.Exception e)
152 e.printStackTrace();
153 return false;
155 testClass.executeMethods(entries[i], param);
157 Summarizer sum = new Summarizer();
158 sum.summarizeUp(entries[i]);
160 if (office != null)
162 office.closeExistingOffice(param, false);
165 LogWriter out = OutProducerFactory.createOutProducer(param);
167 out.initialize(entries[i], true);
168 out.summary(entries[i]);
169 returnVal &= entries[i].State.endsWith("OK");
171 return returnVal;