bump product version to 5.0.4.1
[LibreOffice.git] / qadevOOo / runner / base / java_complex.java
blobf1f6698254741a1ed11ddced50b14b5810a0869c
1 /*
2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 package base;
20 import complexlib.ComplexTestCase;
21 import util.DynamicClassLoader;
22 import share.DescGetter;
23 import stats.OutProducerFactory;
24 import helper.ComplexDescGetter;
25 import helper.AppProvider;
26 import helper.CfgParser;
27 import share.DescEntry;
28 import share.LogWriter;
29 import stats.Summarizer;
30 import lib.TestParameters;
31 import util.PropertyName;
33 /**
34 * Test base for executing a java complex test.
35 * @see base.TestBase
37 public class java_complex implements TestBase
40 /**
41 * This function executes the complex tests given as parameter "-o" or "TestJob". It querys for the correspond class
42 * and crates the JobDescription.
43 * @return true of all tests run successfully, else false
45 public boolean executeTest(TestParameters param)
48 // get the test job
49 String testJob = ((String) param.get("TestJob"));
51 DescGetter descGetter = new ComplexDescGetter();
52 // get the test jobs
53 DescEntry[] entries = descGetter.getDescriptionFor(testJob, null, true);
54 return executeTest(param, entries);
58 /**
59 * This function run the given DescEntry[] as ComplexTest
60 * @return true of all tests run successfully, else false
62 public boolean executeTest(TestParameters param, DescEntry[] entries)
64 DynamicClassLoader dcl = new DynamicClassLoader();
65 ComplexTestCase testClass = null;
66 boolean returnVal = true;
68 // the concept of the TimeOut depends on runner logs. If the runner log,
69 // for example to start a test method, the timeout was reset. This is not
70 // while the test itself log something like "open document...".
71 // A property of complex test could be that it has only one test method
72 // which works for several minutes. In this case the TimeOut get not trigger
73 // and the office was killed.
74 // In complex tests just use "ThreadTimeOut" as timeout.
76 for (int i = 0; i < entries.length; i++)
79 if (entries[i] == null)
81 continue;
83 String iniName = entries[i].longName;
84 iniName = iniName.replace('.', '/');
85 CfgParser ini = new CfgParser(iniName + ".props");
86 ini.getIniParameters(param);
88 LogWriter log = (LogWriter) dcl.getInstance((String) param.get("LogWriter"));
90 AppProvider office = null;
91 if (!param.getBool("NoOffice"))
93 try
95 office = (AppProvider) dcl.getInstance("helper.OfficeProvider");
96 Object msf = office.getManager(param);
97 if (msf == null)
99 returnVal = false;
100 continue;
102 param.put("ServiceFactory", msf);
104 catch (IllegalArgumentException e)
106 office = null;
109 log.initialize(entries[i], param.getBool(PropertyName.LOGGING_IS_ACTIVE));
110 entries[i].Logger = log;
112 // create an instance
115 testClass = (ComplexTestCase) dcl.getInstance(entries[i].longName);
117 catch (java.lang.Exception e)
119 e.printStackTrace();
120 return false;
122 testClass.executeMethods(entries[i], param);
124 Summarizer sum = new Summarizer();
125 sum.summarizeUp(entries[i]);
127 if (office != null)
129 office.closeExistingOffice(param, false);
132 LogWriter out = OutProducerFactory.createOutProducer(param);
134 out.initialize(entries[i], true);
135 out.summary(entries[i]);
136 returnVal &= entries[i].State.endsWith("OK");
138 return returnVal;