Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / qadevOOo / runner / base / java_complex.java
blobe0f6b796732a8f942c4ba1ac7b5fb73ef24cd2d8
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;
32 import java.io.UnsupportedEncodingException;
34 /**
35 * Test base for executing a java complex test.
36 * @see base.TestBase
38 public class java_complex implements TestBase
41 /**
42 * This function executes the complex tests given as parameter "-o" or "TestJob". It queries for the correspond class
43 * and creates the JobDescription.
44 * @return true of all tests run successfully, else false
46 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);
55 if (entries == null) {
56 System.out.println("Couldn't get Description for Job: " + testJob);
58 return false;
61 return executeTest(param, entries);
64 /**
65 * This function run the given DescEntry[] as ComplexTest
66 * @return true of all tests run successfully, else false
68 public boolean executeTest(TestParameters param, DescEntry[] entries)
70 DynamicClassLoader dcl = new DynamicClassLoader();
71 ComplexTestCase testClass = null;
72 boolean returnVal = true;
74 // the concept of the TimeOut depends on runner logs. If the runner log,
75 // for example to start a test method, the timeout was reset. This is not
76 // while the test itself log something like "open document...".
77 // A property of complex test could be that it has only one test method
78 // which works for several minutes. In this case the TimeOut get not trigger
79 // and the office was killed.
80 // In complex tests just use "ThreadTimeOut" as timeout.
82 for (int i = 0; i < entries.length; i++)
85 if (entries[i] == null)
87 continue;
89 String iniName = entries[i].longName;
90 iniName = iniName.replace('.', '/');
91 CfgParser ini = new CfgParser(iniName + ".props");
92 ini.getIniParameters(param);
94 LogWriter log = (LogWriter) dcl.getInstance((String) param.get("LogWriter"));
96 AppProvider office = null;
97 if (!param.getBool("NoOffice"))
99 try
101 office = (AppProvider) dcl.getInstance("helper.OfficeProvider");
102 Object msf = office.getManager(param);
103 if (msf == null)
105 returnVal = false;
106 continue;
108 param.put("ServiceFactory", msf);
110 catch (IllegalArgumentException e)
112 office = null;
114 catch (UnsupportedEncodingException e)
116 office = null;
119 log.initialize(entries[i], param.getBool(PropertyName.LOGGING_IS_ACTIVE));
120 entries[i].Logger = log;
122 // create an instance
125 testClass = (ComplexTestCase) dcl.getInstance(entries[i].longName);
127 catch (java.lang.Exception e)
129 e.printStackTrace();
130 return false;
132 testClass.executeMethods(entries[i], param);
134 Summarizer sum = new Summarizer();
135 sum.summarizeUp(entries[i]);
137 if (office != null)
139 office.closeExistingOffice(param, false);
142 LogWriter out = OutProducerFactory.createOutProducer(param);
144 out.initialize(entries[i], true);
145 out.summary(entries[i]);
146 returnVal &= entries[i].State.endsWith("OK");
148 return returnVal;