1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
30 import java
.util
.Properties
;
32 import lib
.TestParameters
;
33 import util
.PropertyName
;
37 * This class parses commandline Argument and stores <br>
38 * them into TestParameter
43 * Parses the commandline argument and puts them<br>
44 * into the TestParameters
47 public void getCommandLineParameter(TestParameters param
, String
[] args
)
49 Properties mapping
= getMapping();
51 for (int i
= 0; i
< args
.length
;)
53 String pName
= getParameterFor(mapping
, args
[i
]).trim();
55 if (pName
.equals("TestJob"))
57 if (args
.length
> (i
+ 1))
59 pValue
= args
[i
].trim() + " " + args
[i
+ 1].trim();
64 pValue
= args
[i
].trim() + " unknown";
70 if ((i
+ 1) < args
.length
)
72 pValue
= args
[i
+ 1].trim();
74 if (pValue
.startsWith("-"))
79 else if (pValue
.startsWith("'"))
82 while (!pValue
.endsWith("'"))
85 pValue
= pValue
+ " " + args
[i
].trim();
88 pValue
= utils
.replaceAll13(pValue
, "'", "");
96 if (pName
.equals("TestDocumentPath"))
99 "DOCPTH", new File(pValue
).getAbsolutePath());
101 else if (pName
.equals(PropertyName
.SRC_ROOT
))
103 System
.setProperty(pName
, pValue
);
114 param
.put(pName
, pValue
);
119 * This method returns the path to a Configuration file <br>
120 * if defined as command line parameter, an empty String elsewhere
122 public String
getIniPath(String
[] args
)
126 for (int i
= 0; i
< args
.length
; i
++)
128 if (args
[i
].equals("-ini"))
130 iniFile
= args
[i
+ 1];
139 * This method returns the path to a Configuration file <br>
140 * if defined as command line parameter, an empty String elsewhere
142 public String
getRunnerIniPath(String
[] args
)
146 for (int i
= 0; i
< args
.length
; i
++)
148 if (args
[i
].equals("-runnerini"))
150 iniFile
= args
[i
+ 1];
159 * This method maps commandline Parameters to TestParameters
161 protected Properties
getMapping()
163 Properties map
= new Properties();
164 map
.setProperty("-cs", "ConnectionString");
165 map
.setProperty("-tb", "TestBase");
166 map
.setProperty("-tdoc", "TestDocumentPath");
167 map
.setProperty("-objdsc", "DescriptionPath");
168 map
.setProperty("-cmd", "AppExecutionCommand");
169 map
.setProperty("-o", "TestJob");
170 map
.setProperty("-sce", "TestJob");
171 map
.setProperty("-p", "TestJob");
172 map
.setProperty("-aca", "AdditionalConnectionArguments");
173 map
.setProperty("-xcl", "ExclusionList");
174 map
.setProperty("-debug", "DebugIsActive");
175 map
.setProperty("-log", "LoggingIsActive");
176 map
.setProperty("-dbout", "DataBaseOut");
177 map
.setProperty("-nca", "NoCwsAttach");
182 protected String
getParameterFor(Properties map
, String name
)
184 String ret
= map
.getProperty(name
);
188 ret
= name
.substring(1);