bump product version to 5.0.4.1
[LibreOffice.git] / qadevOOo / runner / helper / CwsDataExchangeImpl.java
blobd9887e1b74c5cda837dc01dfb55308b1860fe4c1
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 .
19 package helper;
21 import java.io.FileWriter;
22 import java.io.IOException;
23 import java.util.ArrayList;
24 import lib.TestParameters;
25 import share.LogWriter;
26 import util.PropertyName;
27 import util.utils;
29 /**
30 * Exchange information to the EIS database
33 public class CwsDataExchangeImpl
36 private final TestParameters param;
37 private final LogWriter log;
38 private final BuildEnvTools bet;
39 private final boolean mDebug;
41 public CwsDataExchangeImpl(TestParameters param, LogWriter log) throws ParameterNotFoundException
43 this.param = param;
44 this.log = log;
45 this.bet = new BuildEnvTools(param, log);
46 mDebug = param.getBool(PropertyName.DEBUG_IS_ACTIVE);
49 /**
50 * Returns all module names which are added to the specified childworkspace
51 * @return a String array of all added modules
53 public ArrayList<String> getModules()
55 // the cwstouched command send its version information to StdErr.
56 // A piping from StdErr to SdtOut the tcsh does not support.
57 // To find the output easily the echo command is used
58 final String[] commands =
60 "echo cwstouched starts here",
61 "cwstouched",
62 "echo cwstouched ends here"
65 final ProcessHandler procHdl = bet.runCommandsInEnvironmentShell(commands, null, 20000);
67 if (mDebug)
69 log.println("---> Output of getModules:");
70 log.println(procHdl.getOutputText());
71 log.println("<--- Output of getModules");
72 log.println("---> Error output of getModules");
73 log.println(procHdl.getErrorText());
74 log.println("<--- Error output of getModules");
77 final String[] outs = procHdl.getOutputText().split("\n");
79 final ArrayList<String> moduleNames = new ArrayList<String>();
80 boolean bStart = false;
81 for (int i = 0; i < outs.length; i++)
83 final String line = outs[i];
84 if (line.startsWith("cwstouched starts here"))
86 bStart = true;
87 continue;
89 if (line.startsWith("cwstouched ends here"))
91 bStart = false;
92 continue;
94 if (bStart && line.length() > 1)
96 moduleNames.add(line);
100 return moduleNames;
104 * Set the test status of cws related UnoAPI tests to the EIS dabase
105 * @param status the status of the UnoAPI test
107 public void setUnoApiCwsStatus(boolean status)
110 FileWriter out = null;
111 String statusFile = null;
115 final String stat = status ? ".PASSED.OK" : ".PASSED.FAILED";
117 statusFile = utils.getUsersTempDir() +
118 System.getProperty("file.separator") +
119 "UnoApiCwsStatus." +
120 (String) param.get(PropertyName.VERSION) +
121 "_" + param.get(PropertyName.OPERATING_SYSTEM) + stat + ".txt";
123 out = new FileWriter(statusFile);
125 out.write(stat);
126 out.flush();
127 out.close();
129 final String[] commands =
131 "cwsattach " + statusFile
134 bet.runCommandsInEnvironmentShell(commands, null, 5000);
137 catch (IOException ex)
139 System.out.println("ERROR: could not attach file '" + statusFile + "' to cws\n" + ex.toString());
141 finally
145 out.close();
147 catch (IOException ex)
149 ex.printStackTrace();