merged tag ooo/DEV300_m102
[LibreOffice.git] / qadevOOo / runner / helper / CwsDataExchangeImpl.java
blob15292f20d7257c14ac46b6188725d3fdc5188673
1 /*
2 *************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
28 package helper;
30 import java.io.FileWriter;
31 import java.io.IOException;
32 import java.util.ArrayList;
33 import lib.TestParameters;
34 import share.CwsDataExchange;
35 import share.LogWriter;
36 import util.PropertyName;
37 import util.utils;
39 /**
40 * Implementaion of the interface CwsDataExchange
41 * @see share.CwsDataExchange
43 public class CwsDataExchangeImpl implements CwsDataExchange
46 private final String cwsName;
47 private final TestParameters param;
48 private final LogWriter log;
49 private final BuildEnvTools bet;
50 private final boolean mDebug;
52 public CwsDataExchangeImpl(String cwsName, TestParameters param, LogWriter log) throws ParameterNotFoundException
54 this.cwsName = cwsName;
55 this.param = param;
56 this.log = log;
57 this.bet = new BuildEnvTools(param, log);
58 mDebug = param.getBool(PropertyName.DEBUG_IS_ACTIVE);
61 public ArrayList getModules()
63 // the cwstouched command send its version information to StdErr.
64 // A piping from StdErr to SdtOut the tcsh does not support.
65 // To find the output easily the echo command is used
66 final String[] commands =
68 "echo cwstouched starts here",
69 "cwstouched",
70 "echo cwstouched ends here"
73 final ProcessHandler procHdl = bet.runCommandsInEnvironmentShell(commands, null, 20000);
75 if (mDebug)
77 log.println("---> Output of getModules:");
78 log.println(procHdl.getOutputText());
79 log.println("<--- Output of getModules");
80 log.println("---> Error output of getModules");
81 log.println(procHdl.getErrorText());
82 log.println("<--- Error output of getModules");
85 final String[] outs = procHdl.getOutputText().split("\n");
87 final ArrayList<String> moduleNames = new ArrayList<String>();
88 boolean bStart = false;
89 for (int i = 0; i < outs.length; i++)
91 final String line = outs[i];
92 if (line.startsWith("cwstouched starts here"))
94 bStart = true;
95 continue;
97 if (line.startsWith("cwstouched ends here"))
99 bStart = false;
100 continue;
102 if (bStart && line.length() > 1)
104 moduleNames.add(line);
108 return moduleNames;
111 public void setUnoApiCwsStatus(boolean status)
114 FileWriter out = null;
115 String statusFile = null;
119 final String stat = status ? ".PASSED.OK" : ".PASSED.FAILED";
121 statusFile = utils.getUsersTempDir() +
122 System.getProperty("file.separator") +
123 "UnoApiCwsStatus." +
124 (String) param.get(PropertyName.VERSION) +
125 "_" + param.get(PropertyName.OPERATING_SYSTEM) + stat + ".txt";
127 out = new FileWriter(statusFile);
129 out.write(stat);
130 out.flush();
131 out.close();
133 final String[] commands =
135 "cwsattach " + statusFile
138 bet.runCommandsInEnvironmentShell(commands, null, 5000);
141 catch (IOException ex)
143 System.out.println("ERROR: could not attach file '" + statusFile + "' to cws\n" + ex.toString());
145 finally
149 out.close();
151 catch (IOException ex)
153 ex.printStackTrace();