Update ooo320-m1
[ooovba.git] / qadevOOo / runner / helper / CwsDataExchangeImpl.java
blobda2dd90d4997fafef5f3e0efcaf6c1406d08dccb
1 /*
2 *************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * Copyright 2008 by Sun Microsystems, Inc.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * $RCSfile: CwsDataExchangeImpl.java,v $
11 * $Revision: 1.2 $
13 * This file is part of OpenOffice.org.
15 * OpenOffice.org is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License version 3
17 * only, as published by the Free Software Foundation.
19 * OpenOffice.org is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License version 3 for more details
23 * (a copy is included in the LICENSE file that accompanied this code).
25 * You should have received a copy of the GNU Lesser General Public License
26 * version 3 along with OpenOffice.org. If not, see
27 * <http://www.openoffice.org/license.html>
28 * for a copy of the LGPLv3 License.
30 ************************************************************************/
31 package helper;
33 import java.io.FileWriter;
34 import java.io.IOException;
35 import java.util.ArrayList;
36 import lib.TestParameters;
37 import share.CwsDataExchange;
38 import share.LogWriter;
39 import util.PropertyName;
40 import util.utils;
42 /**
43 * Implementaion of the interface CwsDataExchange
44 * @see share.CwsDataExchange
46 public class CwsDataExchangeImpl implements CwsDataExchange
49 private final String cwsName;
50 private final TestParameters param;
51 private final LogWriter log;
52 private final BuildEnvTools bet;
53 private final boolean mDebug;
55 public CwsDataExchangeImpl(String cwsName, TestParameters param, LogWriter log) throws ParameterNotFoundException
57 this.cwsName = cwsName;
58 this.param = param;
59 this.log = log;
60 this.bet = new BuildEnvTools(param, log);
61 mDebug = param.getBool(PropertyName.DEBUG_IS_ACTIVE);
64 public ArrayList getModules()
66 // the cwstouched command send its version information to StdErr.
67 // A piping from StdErr to SdtOut the tcsh does not support.
68 // To find the output easily the echo command is used
69 final String[] commands =
71 "echo cwstouched starts here",
72 "cwstouched",
73 "echo cwstouched ends here"
76 final ProcessHandler procHdl = bet.runCommandsInEnvironmentShell(commands, null, 20000);
78 if (mDebug)
80 log.println("---> Output of getModules:");
81 log.println(procHdl.getOutputText());
82 log.println("<--- Output of getModules");
83 log.println("---> Error output of getModules");
84 log.println(procHdl.getErrorText());
85 log.println("<--- Error output of getModules");
88 final String[] outs = procHdl.getOutputText().split("\n");
90 final ArrayList<String> moduleNames = new ArrayList<String>();
91 boolean bStart = false;
92 for (int i = 0; i < outs.length; i++)
94 final String line = outs[i];
95 if (line.startsWith("cwstouched starts here"))
97 bStart = true;
98 continue;
100 if (line.startsWith("cwstouched ends here"))
102 bStart = false;
103 continue;
105 if (bStart && line.length() > 1)
107 moduleNames.add(line);
111 return moduleNames;
114 public void setUnoApiCwsStatus(boolean status)
117 FileWriter out = null;
118 String statusFile = null;
122 final String stat = status ? ".PASSED.OK" : ".PASSED.FAILED";
124 statusFile = utils.getUsersTempDir() +
125 System.getProperty("file.separator") +
126 "UnoApiCwsStatus." +
127 (String) param.get(PropertyName.VERSION) +
128 "_" + param.get(PropertyName.OPERATING_SYSTEM) + stat + ".txt";
130 out = new FileWriter(statusFile);
132 out.write(stat);
133 out.flush();
134 out.close();
136 final String[] commands =
138 "cwsattach " + statusFile
141 bet.runCommandsInEnvironmentShell(commands, null, 5000);
144 catch (IOException ex)
146 System.out.println("ERROR: could not attach file '" + statusFile + "' to cws\n" + ex.toString());
148 finally
152 out.close();
154 catch (IOException ex)
156 ex.printStackTrace();