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 .
21 import java
.io
.FileWriter
;
22 import java
.io
.IOException
;
23 import java
.util
.ArrayList
;
24 import lib
.TestParameters
;
25 import share
.CwsDataExchange
;
26 import share
.LogWriter
;
27 import util
.PropertyName
;
31 * Implementaion of the interface CwsDataExchange
32 * @see share.CwsDataExchange
34 public class CwsDataExchangeImpl
implements CwsDataExchange
37 private final TestParameters param
;
38 private final LogWriter log
;
39 private final BuildEnvTools bet
;
40 private final boolean mDebug
;
42 public CwsDataExchangeImpl(String cwsName
, TestParameters param
, LogWriter log
) throws ParameterNotFoundException
46 this.bet
= new BuildEnvTools(param
, log
);
47 mDebug
= param
.getBool(PropertyName
.DEBUG_IS_ACTIVE
);
50 public ArrayList
<String
> getModules()
52 // the cwstouched command send its version information to StdErr.
53 // A piping from StdErr to SdtOut the tcsh does not support.
54 // To find the output easily the echo command is used
55 final String
[] commands
=
57 "echo cwstouched starts here",
59 "echo cwstouched ends here"
62 final ProcessHandler procHdl
= bet
.runCommandsInEnvironmentShell(commands
, null, 20000);
66 log
.println("---> Output of getModules:");
67 log
.println(procHdl
.getOutputText());
68 log
.println("<--- Output of getModules");
69 log
.println("---> Error output of getModules");
70 log
.println(procHdl
.getErrorText());
71 log
.println("<--- Error output of getModules");
74 final String
[] outs
= procHdl
.getOutputText().split("\n");
76 final ArrayList
<String
> moduleNames
= new ArrayList
<String
>();
77 boolean bStart
= false;
78 for (int i
= 0; i
< outs
.length
; i
++)
80 final String line
= outs
[i
];
81 if (line
.startsWith("cwstouched starts here"))
86 if (line
.startsWith("cwstouched ends here"))
91 if (bStart
&& line
.length() > 1)
93 moduleNames
.add(line
);
100 public void setUnoApiCwsStatus(boolean status
)
103 FileWriter out
= null;
104 String statusFile
= null;
108 final String stat
= status ?
".PASSED.OK" : ".PASSED.FAILED";
110 statusFile
= utils
.getUsersTempDir() +
111 System
.getProperty("file.separator") +
113 (String
) param
.get(PropertyName
.VERSION
) +
114 "_" + param
.get(PropertyName
.OPERATING_SYSTEM
) + stat
+ ".txt";
116 out
= new FileWriter(statusFile
);
122 final String
[] commands
=
124 "cwsattach " + statusFile
127 bet
.runCommandsInEnvironmentShell(commands
, null, 5000);
130 catch (IOException ex
)
132 System
.out
.println("ERROR: could not attach file '" + statusFile
+ "' to cws\n" + ex
.toString());
140 catch (IOException ex
)
142 ex
.printStackTrace();