Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / qadevOOo / runner / base / java_complex.java
blob212c9337778fbda6ba5de4e21f895592ab568694
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 queries 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)
47 // get the test job
48 String testJob = ((String) param.get("TestJob"));
50 DescGetter descGetter = new ComplexDescGetter();
51 // get the test jobs
52 DescEntry[] entries = descGetter.getDescriptionFor(testJob, null, true);
54 if (entries == null) {
55 System.out.println("Couldn't get Description for Job: " + testJob);
57 return false;
60 return executeTest(param, entries);
63 /**
64 * This function run the given DescEntry[] as ComplexTest
65 * @return true of all tests run successfully, else false
67 public boolean executeTest(TestParameters param, DescEntry[] entries)
69 DynamicClassLoader dcl = new DynamicClassLoader();
70 ComplexTestCase testClass = null;
71 boolean returnVal = true;
73 // the concept of the TimeOut depends on runner logs. If the runner log,
74 // for example to start a test method, the timeout was reset. This is not
75 // while the test itself log something like "open document...".
76 // A property of complex test could be that it has only one test method
77 // which works for several minutes. In this case the TimeOut get not trigger
78 // and the office was killed.
79 // In complex tests just use "ThreadTimeOut" as timeout.
81 for (int i = 0; i < entries.length; i++)
84 if (entries[i] == null)
86 continue;
88 String iniName = entries[i].longName;
89 iniName = iniName.replace('.', '/');
90 CfgParser ini = new CfgParser(iniName + ".props");
91 ini.getIniParameters(param);
93 LogWriter log = (LogWriter) dcl.getInstance((String) param.get("LogWriter"));
95 AppProvider office = null;
96 if (!param.getBool("NoOffice"))
98 try
100 office = (AppProvider) dcl.getInstance("helper.OfficeProvider");
101 Object msf = office.getManager(param);
102 if (msf == null)
104 returnVal = false;
105 continue;
107 param.put("ServiceFactory", msf);
109 catch (IllegalArgumentException e)
111 office = null;
114 log.initialize(entries[i], param.getBool(PropertyName.LOGGING_IS_ACTIVE));
115 entries[i].Logger = log;
117 // create an instance
120 testClass = (ComplexTestCase) dcl.getInstance(entries[i].longName);
122 catch (java.lang.Exception e)
124 e.printStackTrace();
125 return false;
127 testClass.executeMethods(entries[i], param);
129 Summarizer sum = new Summarizer();
130 sum.summarizeUp(entries[i]);
132 if (office != null)
134 office.closeExistingOffice(param, false);
137 LogWriter out = OutProducerFactory.createOutProducer(param);
139 out.initialize(entries[i], true);
140 out.summary(entries[i]);
141 returnVal &= entries[i].State.endsWith("OK");
143 return returnVal;